Git Product home page Git Product logo

action-center-platform's Introduction

Build Status

Action Center Platform

The Action Center Platform is an online organizing tool maintained by EFF. Administrators can create targeted campaigns where users sign petitions, contact legislators, and engage on social media.

Setup

Follow these instructions to run the Action Center using Docker (recommended). To run the Action Center without Docker, see setup without Docker.

  1. Install Docker (instructions) and Docker Compose (instructions).
  2. git clone https://github.com/EFForg/action-center-platform.git
  3. Copy docker-compose.yml.example to docker-compose.yml, and .env.example to .env. Fill in the variables in .env according to the instructions in that file. See notable dependencies for hints.
  4. Build the docker image: sudo docker-compose build
  5. Run the application: sudo docker-compose up
  6. In a new tab, get a bash shell with access to your app: sudo docker-compose exec app bash.
    1. If you aren't running migrations automatically, run rake db:migrate to migrate the database.
    2. Run rake congress:update to populate CongressMember table.

Notable Dependencies

  • Amazon S3 secret key and key id
    • Allows admins to upload images for the ActionPages
  • SmartyStreets API key and id
    • Allows Congress members to be looked up for users
  • Phantom of the Capitol whitelisting on server side?
    • Allows users to submit e-messages to congress
  • Call Congress url and API key
    • Connects calls between citizens and their congress person using the Twilio API

Using the Action Center

Action Center administrators can create four types of actions:

  • Call Action
    • A user is connected to a political leader by phone, leaving a message or sometimes speaking to an aid.
    • The user is shown a script to read and enters their phone number and email
    • When they submit their info, they are called and the process begins.
  • Congress Action
    • A user stepped through a four-part form to submit their comments to their congress person.
    • Page 1 asks for the user's street address and zip code.
    • Based on this information, page 2 displays the user's representatives. User can select which representatives they wish to contact. Then they choose what to fill in for whatever required fields for each representative selected.
    • Page 3 asks the user to customize the message to be delivered.
    • Page 4 is the Thank You page with share links for social media.
    • When creating the action, admin can choose House, Senate, Both or specific legislators
  • Petition Action
    • A user signs a petition, leaving an email address and sometimes location data.
    • Optionally, users can petition local institutions (like universities) and see signatures by institution.
  • Tweet Action
    • A user is invited to join a tweet action using their twitter account.
  • Email Action

Shared Elements of All Actions

  • User is presented with a Thank You page at the end where they are invited to share the action via social media.
  • When creating an action, admin can add partner organizations.
  • Admin can also customize share messages and thank you email.
  • Admin chooses a banner image form the library
  • The title for the action form is always "Take Action".

Administering Users

To get started using the Action Center, create a user and grant them admin privileges. Administrators can create, track, and manage campaigns.

To create an admin user:

  1. If the user doesn't exist yet, create them through the web interface by following the register link in the top nav.
  2. Run the rake task to grant them admin access (including square brackets):
rake users:add_admin[[email protected]]

New users will need to complete an e-mail confirmation in order to log in. Administrators can access admin features by clicking admin in the nav.

To remove an admin user:

rake users:remove_admin[[email protected]]

To list all admin users:

rake users:list_admins

Delayed Jobs and Cron

Action Center uses DelayedJob to perform certain tasks outside of a web request context. See that repository for information regarding how to run a delayed job worker. If you are deploying with Docker, our docker-compose.yml.example shows how to create a service which processes the job queue indefinitely.

You may also want to automate certain other tasks (such as rake signatures:deduplicate and rake congress:update) to run occasionally. For those deploying with Docker, docker-compose.yml.example illustrates how to create a service which runs these commands periodically using cron.

Embedding Actions

Embedding actions is simple. Just include the following HTML on the page you want the action to be embedded:

<script type="text/javascript" src="https://act.eff.org/action/embed"></script>
<a class="action-center-widget" href="https://act.eff.org/action/shut-the-nsa-s-backdoor-to-the-internet">Take part in the action!</a>

The link href should point to the action page you wish to embed. You may add ?nosignup=1 to the URL to get newsletter signup fields omitted from the action.

If you want to get fancy, you can modify the embed code to include some of the following parameters, all of which are optional:

<script type="text/javascript">
    var ac_embed = {};
    ac_embed.css = "https://example.com/hello.css"; // specify a css file url. File must be globally available (i.e. on the Internet, not local or staging).
    ac_embed.width = 500; // specify a width manually
    ac_embed.no_css = true; // remove all default styles
    ac_embed.css_content = "#some_elem"; // specify an element which itself contains some styles
    ac_embed.bioguide_ids = ["ID1", "ID2"...] // bioguide IDs of congress members to target
</script>
<script id="some_div" type="text/x-css-content">
    body{
        background-color: blue;
    }
</script>
<script type="text/javascript" src="https://act.eff.org/action/embed"></script>
<a id="action-center-widget" href="https://act.eff.org/action/shut-the-nsa-s-backdoor-to-the-internet">Take part in the action!</a>

Testing

To run the full test suite, simply run rake with no arguments.

Rspec tests are used for unit testing the app, and some integration testing. Cucumber tests are used for testing API keys, javascript tests, and feature tests.

We use WebMock to stub backend requests to third party services and Puffing Billy to stub frontend (Ajax) requests. Puffing Billy will cache unrecognized requests and play them back during future test runs. To prevent Puffing Billy from making any new requests, set DISABLE_PUFFING_BILLY_REQUESTS=true.

Linting

rake will also run our linting:

Rubocop checks for consistent style across the Ruby areas of the codebase. We use a modified version of Rubocop-Github to stay consistent with SEC.

Sass-lint checks for consistent style across the stylesheets. Our .sass-lint file is derived from SEC.

Deployment

For notes related to deploying Action Center in production, see the project wiki.

Acknowledgements

This project was created by Lilia Kai, Thomas Davis, and Sina Khanifar. Large portions of the codebase are directly attributable to them, while under the employ or contractorship of the Electronic Frontier Foundation in 2014. Thank you Lilia, Thomas, and Sina! The Action Center is currently maintained by the EFF Engineering and Design team.

Styling

The styling is done with SCSS. The partials files are in the stylesheets directory. Admin files are in their own subdirectory.

Bootstrap is also used for much of the styling. Please see the stylesheets/application/bootstrap-custom.scss for what styles may be used.

Bootstrap is used only for styling, not for javascript.

File Structure

  • The home page layout is in views/welcome/index.html.erb.
  • The main internal layout is in views/layouts/application.html.erb.
  • Individiual action views are in views/tools/.
  • User pages are in views/devise.
  • All admin layouts are in views/admin.

Licensing

See the LICENSE file for licensing information. This is applicable to the entire project, sans any 3rd party libraries that may be included.

action-center-platform's People

Contributors

alexymik avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar eff-test avatar esoterik avatar fv42wid avatar hainish avatar jamiecalder avatar k-stewart avatar lenazun avatar lschatzkin avatar maximillianh avatar mfb avatar squiggy avatar thenotary avatar vbrown608 avatar wioux avatar wtcruft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

action-center-platform's Issues

Add ability to mark ActionPages as being related to other action pages

For instance, with regards to the TPP issues, we have the following action pages:

  • Stop the TPP's Copyright Trap in Malaysia
  • Stop the TPP's Copyright Trap in Canada
  • Stop the TPP's Copyright Trap in New Zealand

There should be a spot, perhaps on the right sidebar, which indicates to users that there are multiple actions related to this issue, and they might want to navigate there in order to take action.

Add filter for admin/action_pages index to hide archived/ victorious pages

The admin/action_pages is pretty messy... listing lots of the old material we don't even think about anymore.

It would make things easier to have a filter dropdown box with options of "current", "archived/ victorious", and "all" so admins can easily see what's current, and set them to be featured.

Before the next production push install new deps

I don't want to forget this as I'm playing around with optomization code:

sudo apt-get install libqt4-dev libqtwebkit-dev

these are deps of the new travis-ci capybara-webkit additions.

Alternatively, I could set up the post-recieve hook to skip installation of development/ test gems, which I thought it was already doing actually.......... That's a best practice so testing never interferese with the production state....

[easy] Remove CallToolConfig

Looks like this does nothing, it was started, and then we went a different way with things? There's a migration and a model. Easy commit unless I'm mistaken.

Security/ Reliability: audit has_heartbeat

We're using a gem 'has_heartbeat' that enables an endbpoint, '/heartbeat' that checks the database connection and uptime of our system.

Is there something logging stats on act.eff.org somewhere?

Maybe this should be removed all-together, airbreak is a dependency of this gem which may being leaking log information that we wouldn't want it to (and has the potential to throw stack-level too deep which either masks the actual root of a critical error, or causes one).

Implement Roles

As it stands, there are two types of users, admins and non-admins. Below is ideal:

Roles:

  • Activist
    • admin as it is now
    • edit ActionPages
  • Administrator
    • grant roles to other users
  • Partner
    • download CSVs
    • define newsletter privacy policies
  • Collaborator
    • View draft campaigns
    • View analytics
    • Remove dummy signatures from petitions

Staging Requirements

The staging server setup is sub-optimal. Act.eff is important and deserves a crazy-go-nuts staging server with all the bells and whistles, such as:

  • A script to automate a fresh copy of the RDS database be made
  • A script that automates an in-sync S3 bucket be cloned

Add Cucumber Tests to test the full stack in key areas

These tests will work after the rspec tests after typing rake. Alternatively the tests will be envoked with cucumber. Firefox will be required. Key features such as loggin in as an admin and creating action_pages will be tested.

Varius Caching Problems

  • act.s.eff.org (fastly)
    ** isn't serving assets with a cache header
    ** It seems to merely be proxying, not caching
  • act.eff.org (fastly)
    ** rails-fastly isn't being used
    ** For logged in: The home page has a cache-control: max-age=0, disabling caching
    *** There are three representations of '', normal, logged in, and admin logged in
    ** Pull out as much configuration from fastly and put it into the app's header writes
    ** Investigate half implemented fastly stuff in app...

act.s.eff.org

This thing was behaving funny, as though fastly wasn't cache and was simply proxying everything. That sucked, but I think it's been fixed or being worked on by fastly now.

fastly gem breadcrums

Hmmmm.... check out the bredcrums surrounding prior attempts at using the fastly gem. looks like some crumbs left behind? https://github.com/EFForg/actioncenter-dontuseforissues/commit/4381bba28f372fb39441d7852ffb5a1e489cdca1#diff-8b7db4d5cc4b8f6dc8feb7030baa2478

Allow targeted tweets to contain arbitrary text (rather than always starting with .@TARGET)

Tweets always begin with .@TARGET_NAME when it might be ideal to work the target name into the middle of the tweet text, such as This totally sux @TARGET_NAME, wtf?

https://github.com/EFForg/action-center-platform/blob/master/app/helpers/action_page_helper.rb#L22-L27

The plot thickens:

https://github.com/EFForg/action-center-platform/blob/master/app/assets/javascripts/application/templates/tweet_individual.jst.ejs#L5

Should removing teh forcing of a .@target as a prefix to the message, and instead make that what starts out in the body of the message when the user is creating a tweet campaign?

I'll need to write a migration to add in the tweet targets to existing tweets so I don't break existing tweet campaigns too (so no easy hotfixing).

Javascript cleanup

Some javascripts are required more than once, possibly for hoisting necessities?

//= require application/sticky_tools
...
//= require_tree ./application
...
//= require application/smarty_streets

TODO:

  • Ensure all the javascripts are cucumber tested
  • Clean up application.js so the requires are in a logical order and have no duplications (and confirm nothings broken due to the new hoisting arrangement)
  • Document the heads of each of the scripts
  • Modernize the js to be hoisted in the head, but engaged in the body

There's some weird stuff preventing turbolinks from being dropped in... like custom manifests...
https://github.com/EFForg/action-center-platform/blob/master/app/controllers/application_controller.rb#L34-L36
https://github.com/EFForg/action-center-platform/blob/master/app/controllers/welcome_controller.rb#L2

Signup flow is broken

After you try to register for an account, the site redirects you to the homepage. This must be a regression that's happened relatively recently, as it definitely wasn't the case before.

The "confirm my account" message is sent to the user, but they should be notified to look for an email in their inbox and that isn't happening.

Why are error messages so terrible sometimes?

I'm encountering the dreaded:

SystemStackError in *
stack level too deep
actionpack (4.1.10) lib/action_dispatch/middleware/reloader.rb:79

I'm still trying to figure out what gives. Been commenting away gems to no avail on my local. I'm getting close though, the specific crash is taking place in /dev/work/web/action-center-platform/app/views/welcome/_meta_tags.html.erb when trying to view the index page.

On line 16:

[4] pry(#<#<Class:0x007f162c3f3bc8>>)> twitter_handle
SystemStackError: stack level too deep
from /ruby-2.1.2@action-center/gems/pry-0.10.1/lib/pry/pry_instance.rb:355

Block repeated login attempts

For example, after 5 failed login attempts, block login to the username for one hour.

This would help mitigate brute force logins for a single account over the course of several months.

Petition export in more useful format

Currently it's possible to export signatures from a petition-type action as a CSV that includes first_name, last_name, email, zipcode, country_code, and created_at. That's not super useful for actually delivering petitions. There should probably be an export tool that creates a file (can still be a CSV) with the full name, the city name, the state abbreviation, and the full country name. It would be nice, too, if that had a semantically meaningful name like $action_name-signature-export-YYYY-MM-DD.csv or something.

Make it so app works without CiviCRM

Without doing much investigation, I just hit the below error while running a cucumber test in a private branch:

ActionView::Template::Error: uninitialized constant CiviCRM::SUPPORTERS_API_KEY
from /home/kentos/dev/work/web/action-center-platform/lib/civicrm.rb:91:in `base_params'

application.yml doesn't define a CiviCRM in my test env.

Allow users to set location data for actions

We want to make a set of options for location data available to users who are creating an action. This will default to international, allowing users to select country, then state or province.

Create "affiliation" resource

Affiliations represent an (institution, relationship) pair - for example (UC Berkeley, student).

Each affiliation is associated with a signature.

Users create affiliations when they sign the petition (if affiliations are enabled).

Default Database

In the README it says:

"By default, the test and development environments are configured to use sqlite3"

This is not the case. The default adapter set in database.yml is pg, and the sqlite3 gem is not included in the Gemfile.

Staging Server tests of commits after 57e7286

Other than the two javascript/ css cherry picks, the last stable commit pushed to production was...

57e7286 Building in support for new recaptcha-style forms

I'm going to push all these commits to the staging server, diagnose them carefully, listing any problems in this thread, and then upon resolution, will push them to the production server.

Commands to undo the commit incase it's fubar:

#  On production SSH
$  rake db:rollback STEP=1

# On dev git repo...
$  git push production 9e9c784:master

That should put things right in less than a minute or so of downtime.

schema.rb cannot be generated with existing migrations

Running rake db:migrate on a fresh database will not generate the same schema that is tracked into this git repo.

Arguments Towards Issue Resolution

As briefly discussed in person, my thoughts on this issue are that:

  • It is unconventional to have a schema.rb that cannot be auto-generated via the rails migration feature
  • It gives me a general feeling that things are buggy/ sloppy
  • External (and possibly some internal) devs will have a slightly dis-similar database schema than our production server

I did a quick speed test and running rake db:schema:load takes 4 seconds, whereas rake db:migrate takes 5. Given that this is a 1-time command in the development cycle, I perceive the performance difference to be negligible.

Precautions with Resolving this Issue

As you pointed out in person, I will make a point to:

  • Not make changes to the production database
  • Not hack that cool hidden rails table until I can find legitimate supporting documentation on doing so

Difference between gh schema.rb and migration generated schema.rb

The difference between the gh schema.rb and the migration generated schema is very small. Basically the gh version contains extra stuff that is not used or accessible to the rails app. For the most part, these extra tables and fields exist because the migration files were created and run, and then deleted, but the schema.rb file was not reverted via rake db:rollback. In a special case... the uuid thing... we ran a migration to enable ossd on the database, but didn't backdate the timestamp on it, which prevented us from using the feature properly.

What's different in the gh schema.rb:

  • An unused table, 'action_page_images' exists, it's migration was eliminated because an alternate implementation was used instead
  • An unused table, locales exists, I can't even find it's migration in the old git repo
  • The action_pages table contains an un-used action_image column with missing migration
  • The action_pages table contains an un-used call_tool boolean, with missing migration (we used call_campaign_id instead, btw)
  • The ID column for ahoy_events is defaulted to uuid_generate_v4() which we didn't set during the enable_ossd episode because we needed to backdate the enable_ossd migration to before the creation of the ahoy_events table (such that uuid_generate_v4 would work)
  • The ID column for visits is defaulted to uuid_generate_v4....

Conditionally show all signatures on action pages

When "show all signatures on the action page" is checked:

  • signatures should appears in the main column below the petition
  • signatures should be paginated
  • the "recent signatures" teaser in the right column should not be visible

Allow org logos below signatures

This could be done by letting staff embed the "all signatures" view partial within the content field (similar to the letter style).

Create "affiliation set" resource

Affiliation sets represent:

  • a list of institutions (ex. U.S. colleges and universities that take government funding)
  • a list of of possible relationships (ex. student, alum, faculty, community member)

Administrators maintain affiliation sets. They should be able to upload a CSV of institutions. Not sure what the best way to let them input relationships is.

Improve internationalization support

Actions in non-english language show up with bits of English thrown in there. That's really jarring.

In particular:

https://act.eff.org/action/o-brasil-construiu-uma-das-melhores-leis-para-internet-do-mundo-impeca-o-congresso-de-aprovar-a-pior

  • Individuals
  • Display another 3
  • The actual EFF Action logo image
  • All the navigation links
  • All those 'bottom of page' links

UPDATE:

There's a config/locals folder, not being fully leveraged... hmmmmm..... search t(:speak_out) to get the gist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.