Exemple #1
0
 public function testLabourCoOpPositionCalc()
 {
     $positions = $this->getAllPositions('calculateAllPolicyPositions', 'Labour');
     $expectedResults = array('810' => array('policy_id' => 810, 'position' => 'voted a mixture of for and against', 'score' => 0.5, 'desc' => 'greater <b>regulation of gambling</b>'));
     $this->assertEquals($expectedResults, $positions);
     $party = new MySociety\TheyWorkForYou\Party('Labour/Co-operative');
     $party->cache_position($positions['810']);
     $position = $party->policy_position(810);
     $expected = 'voted a mixture of for and against';
     $this->assertEquals($expected, $position);
 }
<?php

include_once dirname(__FILE__) . '/../www/includes/easyparliament/init.php';
$parties = MySociety\TheyWorkForYou\Party::getParties();
$policies = new MySociety\TheyWorkForYou\Policies();
$party_count = 0;
foreach ($parties as $party) {
    $party = new MySociety\TheyWorkForYou\Party($party);
    $positions = $party->calculateAllPolicyPositions($policies);
    if (count($positions)) {
        $party_count++;
    }
    foreach ($positions as $position) {
        $party->cache_position($position);
    }
}
print "cached positions for {$party_count} parties\n";
Exemple #3
0
        // data for the 'what else would you like to see' question box
        $data['user_code'] = bin2hex(urandom_bytes(16));
        $data['auth_signature'] = auth_sign_with_shared_secret($data['user_code'], OPTION_SURVEY_SECRET);
        $data['page_url'] = "http://" . DOMAIN . $_SERVER['REQUEST_URI'] . ($policyID ? '&' : '?') . 'answered=1';
        $data['answered_q'] = $answered_q;
        // Send the output for rendering
        MySociety\TheyWorkForYou\Renderer::output('mp/divisions', $data);
        break;
    case '':
    default:
        $policiesList = new MySociety\TheyWorkForYou\Policies();
        $policies = $policiesList->limitToSet('summary')->shuffle();
        // Generate limited voting record list
        $data['policyPositions'] = new MySociety\TheyWorkForYou\PolicyPositions($policies, $MEMBER, 6);
        // generate party policy diffs
        $party = new MySociety\TheyWorkForYou\Party($MEMBER->party());
        $positions = new MySociety\TheyWorkForYou\PolicyPositions($policiesList, $MEMBER);
        $party_positions = $party->getAllPolicyPositions($policiesList);
        $policy_diffs = $MEMBER->getPartyPolicyDiffs($party, $policiesList, $positions, true);
        $data['sorted_diffs'] = $policy_diffs;
        $data['party_positions'] = $party_positions;
        $data['positions'] = $positions->positionsById;
        $data['policies'] = $policiesList->getPolicies();
        // Send the output for rendering
        MySociety\TheyWorkForYou\Renderer::output('mp/profile', $data);
        break;
}
/////////////////////////////////////////////////////////
// SUPPORTING FUNCTIONS
/* Person lookup functions */
function get_person_by_id($pid)