Skip to content

Commit

Permalink
[#994] First version of report page
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBrandt committed Jan 15, 2015
1 parent 15aace1 commit 36b77fd
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 23 deletions.
32 changes: 19 additions & 13 deletions akvo/rsr/migrations/0079_focus_areas_to_sectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,29 @@ class Migration(DataMigration):
def forwards(self, orm):
for focus_area in orm.FocusArea.objects.all():
if not focus_area.id == 3:
sector_code = FOCUSAREA_TO_SECTOR_MAPPING[focus_area.pk]
projects = orm.Project.objects.filter(categories__in=focus_area.categories.all())
for project in projects:
sector = orm.Sector.objects.create(project=project)
sector.vocabulary = 2
sector.sector_code = sector_code
sector.save()
try:
sector_code = FOCUSAREA_TO_SECTOR_MAPPING[focus_area.pk]
projects = orm.Project.objects.filter(categories__in=focus_area.categories.all())
for project in projects:
sector = orm.Sector.objects.create(project=project)
sector.vocabulary = 2
sector.sector_code = sector_code
sector.save()
except:
pass

for project in orm.Project.objects.all():
categories = project.categories.all()
for category in categories:
sector_codes = CATEGORY_TO_SECTOR_MAPPING[category.pk]
for sector_code in sector_codes:
sector = orm.Sector.objects.create(project=project)
sector.vocabulary = 1
sector.sector_code = sector_code
sector.save()
try:
sector_codes = CATEGORY_TO_SECTOR_MAPPING[category.pk]
for sector_code in sector_codes:
sector = orm.Sector.objects.create(project=project)
sector.vocabulary = 1
sector.sector_code = sector_code
sector.save()
except:
pass

def backwards(self, orm):
pass
Expand Down
3 changes: 3 additions & 0 deletions akvo/rsr/models/indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Indicator(models.Model):
def __unicode__(self):
return self.title

def iati_measure(self):
return dict(codelists.INDICATOR_MEASURE)[self.measure]

class Meta:
app_label = 'rsr'
verbose_name = _(u'indicator')
Expand Down
3 changes: 3 additions & 0 deletions akvo/rsr/models/planned_disbursement.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class PlannedDisbursement(models.Model):
def __unicode__(self):
return self.value

def iati_currency(self):
return dict(codelists.CURRENCY)[self.currency]

class Meta:
app_label = 'rsr'
verbose_name = _(u'planned disbursement')
Expand Down
10 changes: 5 additions & 5 deletions akvo/rsr/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,19 +677,19 @@ def iati_project_scope(self):
return dict(codelists.ACTIVITY_SCOPE)[self.project_scope]

def iati_collaboration_type(self):
return dict(codelists.COLLABORATION_TYPE)[self.collaboration_type]
return dict([code[:2] for code in codelists.COLLABORATION_TYPE])[self.collaboration_type]

def iati_default_flow_type(self):
return dict(codelists.FLOW_TYPE)[self.default_flow_type]
return dict([code[:2] for code in codelists.FLOW_TYPE])[self.default_flow_type]

def iati_default_finance_type(self):
return dict(codelists.FINANCE_TYPE)[self.default_finance_type]
return dict([code[:2] for code in codelists.FINANCE_TYPE])[self.default_finance_type]

def iati_default_aid_type(self):
return dict(codelists.AID_TYPE)[self.default_aid_type]
return dict([code[:2] for code in codelists.AID_TYPE])[self.default_aid_type]

def iati_default_tied_status(self):
return dict(codelists.TIED_STATUS)[self.default_tied_status]
return dict([code[:2] for code in codelists.TIED_STATUS])[self.default_tied_status]

def sector_names(self):
from .sector import Sector
Expand Down
3 changes: 3 additions & 0 deletions akvo/rsr/models/project_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class ProjectCondition(models.Model):
type = ValidXMLCharField(_(u'condition type'), blank=True, max_length=1, choices=codelists.CONDITION_TYPE)
attached = models.NullBooleanField(_(u'attached'), blank=True)

def iati_type(self):
return dict(codelists.CONDITION_TYPE)[self.type]

class Meta:
app_label = 'rsr'
verbose_name = _(u'condition')
Expand Down
17 changes: 12 additions & 5 deletions akvo/rsr/models/project_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ class ProjectDocument(models.Model):
)
language = ValidXMLCharField(_(u'language'), max_length=2, blank=True, choices=codelists.LANGUAGE)

def __unicode__(self):
return self.title

def show_link(self):
return u'<a href="%s">%s</a>' % (self.url, self.title,)

def iati_category(self):
return dict([codelist[:2] for codelist in codelists.DOCUMENT_CATEGORY])[self.category]

def iati_language(self):
return dict(codelists.LANGUAGE)[self.language]

class Meta:
app_label = 'rsr'
verbose_name = _(u'project document')
verbose_name_plural = _(u'project documents')
ordering = ['-id', ]

def __unicode__(self):
return self.title

def show_link(self):
return u'<a href="%s">%s</a>' % (self.url, self.title,)
3 changes: 3 additions & 0 deletions akvo/rsr/models/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Result(models.Model):
def __unicode__(self):
return self.title

def iati_type(self):
return dict(codelists.RESULT_TYPE)[self.type]

class Meta:
app_label = 'rsr'
verbose_name = _(u'result')
Expand Down
9 changes: 9 additions & 0 deletions akvo/rsr/models/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class Transaction(models.Model):
def __unicode__(self):
return self.value

def iati_currency(self):
return dict(codelists.CURRENCY)[self.currency]

def iati_transaction_type(self):
return dict([code[:2] for code in codelists.TRANSACTION_TYPE])[self.transaction_type]

def iati_disbursement_channel(self):
return dict(codelists.DISBURSEMENT_CHANNEL)[self.disbursement_channel]

class Meta:
app_label = 'rsr'
verbose_name = _(u'transaction')
Expand Down
171 changes: 171 additions & 0 deletions akvo/templates/project_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ <h4>{% trans "Product Budget Items" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Label" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Value" %}</th>
<th>{% trans "Currency" %}</th>
Expand All @@ -244,6 +245,7 @@ <h4>{% trans "Product Budget Items" %}</h4>
<tbody>
{% for budget_item in project.budget_items.all %}
<tr>
<td>{% if budget_item.label %}{{budget_item.label}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if budget_item.type %}{{budget_item.iati_type}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if budget_item.amount %}{{budget_item.amount}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if budget_item.currency %}{{budget_item.iati_currency}}%{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
Expand All @@ -256,6 +258,175 @@ <h4>{% trans "Product Budget Items" %}</h4>
</tbody>
</table>
{% endif %}
{% if project.planned_disbursements.all %}
<h4>{% trans "Planned Disbursements" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Value" %}</th>
<th>{% trans "Currency" %}</th>
<th>{% trans "Start Date" %}</th>
<th>{% trans "End Date" %}</th>
<th>{% trans "Value Date" %}</th>
<th>{% trans "Original/ Revised" %}</th>
</tr>
</thead>
<tbody>
{% for pd in project.planned_disbursements.all %}
<tr>
<td>{% if pd.value %}{{pd.value}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if pd.currency %}{{pd.iati_currency}}%{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if pd.period_start %}{{pd.period_start}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if pd.period_end %}{{pd.period_end}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if pd.value_date %}{{pd.value_date}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td><i>({% trans "To do" %})</i></td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if project.transactions.all %}
<h4>{% trans "Transactions" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Reference" %}</th>
<th>{% trans "Value" %}</th>
<th>{% trans "Currency" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Date" %}</th>
<th>{% trans "Value Date" %}</th>
<th>{% trans "Description" %}</th>
<th>{% trans "Provider Organisation" %}</th>
<th>{% trans "Provider ID" %}</th>
<th>{% trans "Provider Activity ID" %}</th>
<th>{% trans "Recipient Organisation" %}</th>
<th>{% trans "Recipient ID" %}</th>
<th>{% trans "Recipient Activity ID" %}</th>
<th>{% trans "Disbursement Channel" %}</th>
</tr>
</thead>
<tbody>
{% for trans in project.transactions.all %}
<tr>
<td>{% if trans.reference %}{{trans.reference}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.value %}{{trans.value}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.currency %}{{trans.iati_currency}}%{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.transaction_type %}{{trans.iati_transaction_type}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.transaction_date %}{{trans.transaction_date}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.value_date %}{{trans.value_date}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.description %}{{trans.description}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.provider_organisation %}{{trans.provider_organisation}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.provider_organisation_ref %}{{trans.provider_organisation_ref}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.provider_organisation_activity %}{{trans.provider_organisation_activity}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.receiver_organisation %}{{trans.receiver_organisation}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.receiver_organisation_ref %}{{trans.receiver_organisation_ref}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.receiver_organisation_activity %}{{trans.receiver_organisation_activity}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if trans.disbursement_channel %}{{trans.iati_disbursement_channel}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if project.documents.all %}
<h4>{% trans "Activity Documents" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Title" %}</th>
<th>{% trans "Category" %}</th>
<th>{% trans "Language" %}</th>
<th>{% trans "Link" %}</th>
</tr>
</thead>
<tbody>
{% for doc in project.documents.all %}
<tr>
<td>{% if doc.title %}{{doc.title}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if doc.category %}{{doc.iati_category}}%{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if doc.language %}{{doc.iati_language}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if doc.url %}{{doc.url}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if project.conditions.all %}
<h4>{% trans "Conditions" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Condition" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Attached" %}</th>
</tr>
</thead>
<tbody>
{% for condition in project.conditions.all %}
<tr>
<td>{% if condition.text %}{{condition.text}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if condition.type %}{{condition.iati_type}}%{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if condition.attached != None %}{% if condition.attached %}{% trans "Attached" %}{% else %}{% trans "Not Attached" %}{% endif %}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% if project.results.all %}
<h4>{% trans "Results" %}</h4>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>{% trans "Result" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Aggregation Status" %}</th>
<th>{% trans "Indicator" %}</th>
<th>{% trans "Measure" %}</th>
<th>{% trans "Ascending" %}</th>
<th>{% trans "Baseline" %}</th>
<th>{% trans "Baseline Year" %}</th>
<th>{% trans "Baseline Value" %}</th>
<th>{% trans "Period Start" %}</th>
<th>{% trans "Period End" %}</th>
<th>{% trans "Target Value" %}</th>
<th>{% trans "Actual Value" %}</th>
</tr>
</thead>
<tbody>
{% for result in project.results.all %}
<tr>
<td>{% if result.title %}{{result.title}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if result.type %}{{result.iati_type}}%{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if result.aggregation_status != None %}{% if result.aggregation_status %}{% trans "Aggregatable" %}{% else %}{% trans "Not Aggregatable" %}{% endif %}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
{% for indicator in result.indicators.all %}
{% if not forloop.first %}
<tr><td></td><td></td><td></td>
{% endif %}
<td>{% if indicator.title %}{{indicator.title}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if indicator.measure %}{{indicator.iati_measure}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if indicator.ascending != None %}{% if indicator.ascending %}{% trans "Ascending" %}{% else %}{% trans "Descending" %}{% endif %}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if indicator.baseline_comment %}{{indicator.baseline_comment}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if indicator.baseline_year %}{{indicator.baseline_year}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if indicator.baseline_value %}{{indicator.baseline_value}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
{% for period in indicator.periods.all %}
{% if not forloop.first %}
<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
{% endif %}
<td>{% if period.period_start %}{{period.period_start}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if period.period_end %}{{period.period_end}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if period.target_value %}{{period.target_value}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
<td>{% if period.actual_value %}{{period.actual_value}}{% else %}<i>({% trans "Information missing" %})</i>{% endif %}</td>
{% empty %}
<td></td><td></td><td></td><td></td>
{% endfor %}
{% empty %}
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
<div class="col-sm-4">
<h4>{% trans "Reporting Organisation" %}</h4>
Expand Down

0 comments on commit 36b77fd

Please sign in to comment.