Skip to content
Browse files

Moved extra fields from the summary field

  • Loading branch information...
1 parent a58d7f0 commit bf1d28ea11e11537c89fed791c74c349148f01b7 @chetan1 committed Aug 9, 2012
Showing with 37 additions and 38 deletions.
  1. +17 −20 protected/components/PopIt/prs.php
  2. +4 −2 protected/models/People.php
  3. +16 −16 protected/views/site/person.php
View
37 protected/components/PopIt/prs.php
@@ -15,29 +15,26 @@ public static function sync()
foreach($people as $p)
{
- if(isset($storedData['organisation'][$p->house]))
- $orgId = $storedData['organisation'][$p->house];
- else
+ if(!isset($storedData['person'][$p->name]))
{
- $call = $popit->add('organisation', array('name' => $p->house));
- $orgId = $call['_id'];
- $storedData['organisation'][$p->house] = $orgId;
- }
-
- $links = $p->getLinks();
+ if(isset($storedData['organisation'][$p->house]))
+ $orgId = $storedData['organisation'][$p->house];
+ else
+ {
+ $call = $popit->add('organisation', array('name' => $p->house));
+ $orgId = $call['_id'];
+ $storedData['organisation'][$p->house] = $orgId;
+ }
- $person = $popit->add('person', array(
- 'name' => $p->name,
- 'summary' => json_encode($p->getExtraData()),
- 'links' => $links,
-
- ));
+ $links = $p->getLinks();
- $position = $popit->add('position', array(
- 'title' => 'Member of ' . $p->house,
- 'person' => $person['_id'],
- 'organisation' => $orgId,
- ));
+ $person = $popit->add('person', $p->getSyncData());
+ $position = $popit->add('position', array(
+ 'title' => 'Member of ' . $p->house,
+ 'person' => $person['_id'],
+ 'organisation' => $orgId,
+ ));
+ }
}
}
View
6 protected/models/People.php
@@ -120,7 +120,7 @@ public function search($query)
public static function getSyncFields()
{
- return array('house', 'state', 'party', 'education', 'educationDetails', 'constituency', 'age', 'gender', 'debates', 'bills', 'questions', 'attendance', 'termStart', 'termEnd', 'nature');
+ return array('name', 'house', 'state', 'party', 'education', 'educationDetails', 'constituency', 'age', 'gender', 'debates', 'bills', 'questions', 'attendance', 'termStart', 'termEnd', 'nature', 'notes');
}
public static function getSearchFields()
@@ -170,14 +170,16 @@ public function getGenderText()
return "Female";
}
- public function getExtraData()
+ public function getSyncData()
{
$fields = self::getSyncFields();
$result = array();
foreach($fields as $f)
$result[$f] = $this->$f;
+ $result['links'] = $this->getLinks();
+
return $result;
}
View
32 protected/views/site/person.php
@@ -3,15 +3,15 @@
<div class="span8">
<div class="hero-unit" id="person-profile">
<h1>
- <?= $person['name'] ?> <span class="small"><i>(<?= $person['summary']['age'] ?>, <?= $person['summary']['gender'] ?>)</i></small>
+ <?= $person['name'] ?> <span class="small"><i>(<?= $person['age'] ?>, <?= $person['gender'] ?>)</i></small>
<div class="shr_classic shareaholic-show-on-load" style="float:right;"></div>
</h1>
- <h2><?= $person['summary']['house'] ?> - <i>
- <?= $person['summary']['nature'] ?>
+ <h2><?= $person['house'] ?> - <i>
+ <?= $person['nature'] ?>
<? if($person->constituency != ''): ?>
from
- <a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person['summary']['constituency'])) ?>">
- <?= $person['summary']['constituency'] ?>
+ <a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person['constituency'])) ?>">
+ <?= $person['constituency'] ?>
</a>
<? endif; ?>
</i></h2>
@@ -21,8 +21,8 @@
Education
</div>
<div class="profile-section-content">
- <a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person['summary']['education'])) ?>"><?= $person['summary']['education'] ?></a>,
- <?= $person['summary']['educationDetails'] ?>
+ <a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person['education'])) ?>"><?= $person['education'] ?></a>,
+ <?= $person['educationDetails'] ?>
</div>
</div>
@@ -32,14 +32,14 @@
</div>
<div class="profile-section-content">
<b>Party</b>:
- <a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person['summary']['party'])) ?>">
- <?= $person['summary']['party'] ?>
+ <a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person['party'])) ?>">
+ <?= $person['party'] ?>
</a><br />
<b>State</b>:
<a href="<?= $this->createAbsoluteUrl('site/search', array('q' => $person->state)) ?>">
- <?= $person['summary']['state'] ?>
+ <?= $person['state'] ?>
</a><br />
- <b>Term</b>: <?= $person['summary']['termStart'] ?> - <?= $person['summary']['termEnd'] ?><br />
+ <b>Term</b>: <?= $person['termStart'] ?> - <?= $person['termEnd'] ?><br />
</div>
</div>
@@ -48,10 +48,10 @@
Statistics
</div>
<div class="profile-section-content">
- <b>Bills</b>: <?= $person['summary']['bills'] ?><br />
- <b>Debates</b>: <?= $person['summary']['debates'] ?><br />
- <b>Questions</b>: <?= $person['summary']['questions'] ?><br />
- <b>Attendance</b>: <?= $person['summary']['attendance'] ?>%<br />
+ <b>Bills</b>: <?= $person['bills'] ?><br />
+ <b>Debates</b>: <?= $person['debates'] ?><br />
+ <b>Questions</b>: <?= $person['questions'] ?><br />
+ <b>Attendance</b>: <?= $person['attendance'] ?>%<br />
</div>
</div>
@@ -60,7 +60,7 @@
Notes
</div>
<div class="profile-section-content">
- <?= $person['summary']['notes'] ?>
+ <?= $person['notes'] ?>
</div>
</div>
<div class="profile-section">

0 comments on commit bf1d28e

Please sign in to comment.
Something went wrong with that request. Please try again.