Permalink
Switch branches/tags
Nothing to show
Commits on Oct 13, 2017
  1. Make requested changes to Mzalendo menu items.

    jacksonj04 committed Oct 13, 2017
    * Remove "Data" and "Newsletter" items
    * Add appropriate redirects
    * Remove "Public Participation"
    * Reshuffle existing "Research" items
Commits on Sep 28, 2017
Commits on Sep 27, 2017
  1. Add a script to import elected candidates' photos from YNR

    mhl committed Sep 26, 2017
    This script uses the YNR IDs that the kenya_import_2017_election_results
    command added to import the photos from YNR and add them to the
    appropriate person in Mzalendo. If there were existing photos of the
    person, the YNR photo is not set as primary, otherwise it would be.
Commits on Sep 26, 2017
  1. Add script to import 2017 Election winners, and data from YNR.

    jacksonj04 committed with mhl Sep 22, 2017
    NB: YNR data has been slightly massaged to correct minor issues like
    place punctuation.
  2. Updated browser stats with latest estimates from Google analytics

    wrightmartin committed Sep 26, 2017
Commits on Sep 22, 2017
  1. [KE] SMS and newsletter links above homepage editorial

    zarino committed Sep 22, 2017
  2. [KE] Fix h3 nesting bug in feeds.js

    zarino committed Sep 22, 2017
    The entire content of each feed item preview was being injected
    into the <h3> tag, causing everything to appear bold. Fixed now.
Commits on Sep 18, 2017
  1. Person attendance: Change wording & clarify methodology

    xybrnet committed Sep 18, 2017
Commits on Sep 12, 2017
  1. Add fuzzy search operator to searches.

    jacksonj04 committed Sep 11, 2017
    Haystack prevents us from easily applying a [fuzziness to the whole search](https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-fuzzy-query.html),
    so this is a workaround which checks to see if a string is entirely
    alphanumeric ASCII characters and spaces, then applies the fuzzy query
    string operator to individual words if so. If not, `AutoQuery()` handles
    escaping special characters and turning boolean patterns such as `AND` into
    actual structured query objects.
    
    For future reference, this workaround is necessary without radically re-working search throughout Pombola to use less Haystack magic and allow us to modify search kwargs as [suggested on Stack Overflow](https://stackoverflow.com/questions/18000714/how-can-i-do-a-fuzzy-search-using-django-haystack-and-the-elasticsearch-backend). @mhl and I spent quite a bit of time digging through exactly what was going on, and this appears to be the most logical solution without serious work.
    
    This does have the following caveats:
    
    * Anything which deviates from a boring alphanumeric ASCII query will not be fuzzed at all.
    * Trying to include boolean patterns via keywords (`OR`) rather than operators (`|`) will break, since the keywords will also be fuzzed.
    * We have no way to adjust any value other than the edit distance (currently set at 1) using query string operators.
    
    For anybody stumbling this way in future, we discovered:
    
    * `build_search_kwargs()` as part of an extended `ElasticsearchSearchBackend` class is definitely where you _would_ logically tell ElasticSearch to make a search fuzzy, however;
    * `AutoQuery()` turns a string into a Haystack structured query object, which when it gets passed to `build_search_kwargs()` makes it nigh-on impossible to extract the original term to use as a value in providing a fuzzy argument, and;
    * Haystack, in `elasticsearch_backend.py` goes back and stomps over your kwargs in unexpected ways.
    
    Recommendations for the future are:
    
    * Move away from ElasticSearch 0.90 at an opportune moment (probably an architecture refresh, this is quite a lot of work to do purely for its own sake), and;
    * Use that opportunity to overhaul searching in Pombola, and move from Haystack to [elasticsearch-dsl](https://elasticsearch-dsl.readthedocs.io/en/latest/).
Commits on Sep 8, 2017
  1. Homepage blog snippets JS: fix the use of 'dataType' in $.ajax

    mhl committed Sep 8, 2017
    Thanks to @zarino for pointing out this mistake - it wasn't actually
    stopping the Javascript from working since jQuery autodetects the
    returned content as XML anyway, but the intention was to specify that
    it should expect XML as the returned content.
Commits on Sep 7, 2017
  1. The Google Feed API is deprecated and no longer works; replace its use

    mhl committed Sep 6, 2017
    The Google Feed API, which we used to fetch an RSS feed in Javascript
    and display it on the homepage, was deprecated and stopped working at
    the end of 2016.
    
    There are similar generic services we could use, but it's not clear how
    stable or trustworthy those would be, and it's almost as simple to
    write our own Javascript for fetching the feed, parsing it and
    rendering it as a list, as this commit does.
    
    For this to work there need to be appropriate CORS headers returned by
    the server returning the RSS feed. For example, in the case of
    Mzalendo, this means that we've added:
    
      Access-Control-Allow-Origin: http://info.mzalendo.com
    
    ... to reponses from http://www.mzalendo.com/blog/
    
    Fixes #2292
  2. Use a supported version of Elasticsearch (< 1)

    mhl committed Sep 7, 2017
    This avoids lots of errors in the test output on Travis. This might
    look like a strangely complicated way of getting a particular version of
    Elasticearch, but it's actually what's recommended by Travis for the
    container-based builds on trusty:
    
      https://docs.travis-ci.com/user/database-setup/#Installing-ElasticSearch-on-trusty-container-based-infrastructure
  3. Fix for "CREATE EXTENSION postgis" failing in the new build environment

    mhl committed Sep 7, 2017
    As described here, this is currently failing on the new container-based
    trusty builds:
    
       travis-ci/travis-ci#6972
    
    This workaround causes Travis builds to be a bit slower, since it's
    having to install additional packages, but fixes the problem for the
    moment.
  4. Update the json gem on Travis before trying bundle install

    mhl committed Sep 7, 2017
    Travis's default build environment is now using Ruby 2.4.1p111; version
    1.8.1 of the json gem doesn't build with this more recent Ruby version.
    Our servers are still using an older version of Ruby, however, so this
    commit just upgrades the json gem for running the tests on Travis.
    
    Two better solutions, but which we don't have time for right now would
    be:
    
     * Use the new rbenv support on our servers to use a more recent version
       of Ruby that matches that on Travis.
    
     * Use libsass instead of the compass gem. This would involve replacing
       quite a few mixins defined in compass, however.
    
    (The Ruby gems are only present so that we have a known working version
    of compass, so a change in the version of the json gem doesn't worry me
    *too* much in terms of reproducibility.)
Commits on Aug 31, 2017
  1. [ZA] Reusable .cta-box component for static pages

    zarino committed Aug 18, 2017
    Fixes #2268.
    
    Example:
    
        <div class="cta-box">
            <p>Things are important</p>
            <h2>You should do this thing</h2>
            <p>
                <a href="#" class="button">Do the thing</a>
            </p>
        </div>
    
    A few generic styles mean you can combine paragraphs, headings, and
    other block elements in whatever order you like and it should still
    look fairly good.
Commits on Aug 16, 2017
  1. Rearrange menu template to match new order of menu items

    jacksonj04 committed Aug 14, 2017
  2. Add tracking of usage of MP search box

    jacksonj04 committed Aug 15, 2017
Commits on Aug 15, 2017
  1. Push test coverage data to Scrutinizer

    jacksonj04 committed Aug 14, 2017
Commits on Aug 14, 2017
  1. Add redirect for /attendance to /mp-attendance

    jacksonj04 committed Aug 14, 2017
Commits on Aug 10, 2017
  1. Remove Experiments logic, to leave winner as permanent effect.

    jacksonj04 committed Aug 10, 2017
    Checked with @wrightmartin, behaviour should only occur on mobile,
    making actual HTML/CSS changes unnecessary.
Commits on Aug 4, 2017
  1. [KE] YNR link on Mzalendo homepage

    zarino committed Aug 4, 2017
Commits on Jul 21, 2017
  1. Add a command to add IEBC codes to MapIt counties and constituencies

    mhl committed Jul 20, 2017
    The recently published candidate lists include the IEBC codes for
    counties and constituencies, which are also used in their shapefiles, so
    seem to be stable identifiers. We should be able to get these codes from
    MapIt lookups, so this command can be used to add those codes to the
    MapIt County (DIS) and Constituency (CON) areas.
Commits on Jul 10, 2017
  1. Load external scripts with protocol https, not http

    mhl committed Jul 10, 2017
    Now that we're using https by default on People's Assembly, we need to
    make sure that no page that's in use is trying to load Javascript from
    insecure URLs. (These scripts will otherwise be blocked by the browser
    - this has already caused the Markdown editor toolbar not to work on
    PA.)
Commits on Jun 30, 2017
  1. Fix session heading margins when there are no sessions to switch to

    mhl committed Jun 30, 2017
  2. ZA: Add a data migration to add ParliamentarySession objects

    mhl committed Jun 30, 2017
    For Kenya, we've created instances of a `ParliamentarySession` model
    to represent a term of a particular house of parliament. (The name is
    a bit misleading - it should probably be `Term` instead.) This was
    introduced primarily so that we could distinguish places from
    different terms with different boundaries. Later we added links to
    views of positions of a particular parliament: the position view, when
    provided with a `session` query parameter, only includes positions
    whose start and end date overlap with the start and end date of the
    corresponding `ParliamentarySession`.
    
    In Pombola, this mechanism provides the only easy way to see all the
    people who were ever a representative in a particular house for a
    given session, which means that since there are no such
    `ParliamentarySession`s for South Africa, the EveryPolitician scraper
    can only ever find the current representatives.
    
    Essentially the only `/position/` URL that's used on People's Assembly
    is the "MP Profiles" page which has been overridden and doesn't
    include the session switch link, so adding these ParliamentarySession
    objects will only affect pages that aren't linked to by default, but
    the following links will still be helpful to the EP scrapers:
    
    * /position/delegate/parliament/ncop/?session=ncop25
    * /position/delegate/parliament/ncop/?session=ncop26
    * /position/member/parliament/national-assembly/?session=na25
    * /position/member/parliament/national-assembly/?session=na26
    
    Note that because these views just look for overlapping dates with a
    session, just creating the `ParliamentarySession` objects is enough -
    they don't need to be linked with positions by foreign keys. (This is
    probably a misfeature.)
    
    PMG have been careful about setting precise start and end dates, so
    this should accurately identify who was really a represenative during
    each session.
Commits on Jun 29, 2017
  1. Always output Facebook app_id meta tag

    chrismytton committed Jun 29, 2017
    Some templates, such as blog posts and person pages, override the
    `open_graph` template block, which means the `fb:app_id` meta tag isn't
    in the HTML for those pages.
    
    To avoid that problem this moves the `fb:app_id` meta tag outside any
    template blocks so that it always appears in the HTML output.
  2. Add social media profile links to Mzalendo homepage

    wrightmartin committed Jun 29, 2017
  3. Output fb:app_id meta tag on all pages

    chrismytton committed Jun 29, 2017
    In order for the Facebook comments plugin to work correctly this meta
    tag needs to be on all pages that contain the comment widget [1]. To
    future proof this I'm putting it into the base template, so that it gets
    included on all pages on the site.
    
    [1]: https://developers.facebook.com/docs/plugins/comments#moderation-setup-instructions