Skip to content
Browse files

add reports_to grouping to ois submission

  • Loading branch information...
1 parent c3bbbb1 commit 026a83b07131163ff51a8fe036233efaf1a0bc74 @leibovic committed Nov 6, 2011
Showing with 30 additions and 18 deletions.
  1. +8 −1 website/models.py
  2. +22 −17 website/templates/sistersonly/elections_ois.html
View
9 website/models.py
@@ -97,11 +97,18 @@ class Office(models.Model):
current_officer = models.ForeignKey(Sister, blank=True, null=True)
chain_of_command = models.IntegerField(default=0, blank=True, null=True)
- reports_to = models.ForeignKey('Office', blank=True, null=True)
+ reports_to = models.ForeignKey('Office', default='EmptyOffice')
+
+ def sort_rank(self):
+ # Sort by reverse chain of command. Add title in case chain_of_command is accidentally tied.
+ return "%s%s" % (100 - self.reports_to.chain_of_command, self.title)
+ sort_rank.short_decription = 'Sort Rank'
def __unicode__(self):
return unicode(self.title)
+EmptyOffice = Office(title="")
+
INTEREST_LEVELS = (
(0, 'No'),
(1, 'Yes'),
View
39 website/templates/sistersonly/elections_ois.html
@@ -26,24 +26,29 @@
<h2>Please indicate your interest level in each position below. Any new forms you submit will replace your old responses.</h2>
<form method="post" action="">
{% csrf_token %}
- <table class="ois-table">
- {% for office in offices %}
- <tr><td>Title:</td><td>{{ office.title }}</td></tr>
- <tr><td>Description:</td><td>{{ office.description }}</td></tr>
- <tr class="radio-row"><td>Are you interested?</td>
- <td>
- <input type="radio" name="{{ office.id }}" id="{{ office.id }}yes" value="1"/>
- <label for="{{ office.id }}yes">Yes</label>
-
- <input type="radio" name="{{ office.id }}" id="{{ office.id }}no" value="0"/>
- <label for="{{ office.id }}no">No</label>
-
- <input type="radio" name="{{ office.id }}" id="{{ office.id }}maybe" value="2"/>
- <label for="{{ office.id }}maybe">Maybe</label>
- </td>
- </tr>
+ {% regroup offices|dictsort:"sort_rank" by reports_to as grouped_offices %}
+ {% for exec_office in grouped_offices %}
+ <h2 class="loi-results-office">{{ exec_office.grouper }}</h2>
+ <table class="ois-table">
+ {% for office in exec_office.list %}
+ <tr><td>Title:</td><td>{{ office.title }}</td></tr>
+ <tr><td>Description:</td><td>{{ office.description }}</td></tr>
+ <tr><td>Reports to:</td><td>{{ office.reports_to }}</td></tr>
+ <tr class="radio-row"><td>Are you interested?</td>
+ <td>
+ <input type="radio" name="{{ office.id }}" id="{{ office.id }}yes" value="1"/>
+ <label for="{{ office.id }}yes">Yes</label>
+
+ <input type="radio" name="{{ office.id }}" id="{{ office.id }}no" value="0"/>
+ <label for="{{ office.id }}no">No</label>
+
+ <input type="radio" name="{{ office.id }}" id="{{ office.id }}maybe" value="2"/>
+ <label for="{{ office.id }}maybe">Maybe</label>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
{% endfor %}
- </table>
<input class="form-submit" type="submit" value="Submit OIS"/>
</form>

0 comments on commit 026a83b

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