Add event details fields to budget model/interface

This commit is contained in:
Yingtong Li 2020-01-17 21:12:07 +11:00
parent 91dddaf694
commit 858eb0564f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
5 changed files with 52 additions and 0 deletions

View File

@ -43,6 +43,25 @@
</div>
</div>
</div>
<div class="ui inline grid field">
<label class="three wide column">Event details</label>
<div class="two wide column">
Date/time
</div>
<div class="nine wide column">
<span class="ui calendar" id="cal_event_dt">
<span class="ui input left icon grid">
<i class="calendar icon" style="z-index: 999;"></i>
<input class="nine wide column" type="text" name="event_dt" value="{{ localtime(revision.event_dt) if revision.event_dt else '' }}">
</span>
</span>
</div>
</div>
<div class="ui inline grid field">
<div class="three wide column"></div>
<div class="four wide column">Estimated no. of attendees</div>
<input class="seven wide column" type="text" name="event_attendees" value="{{ revision.event_attendees or '' }}">
</div>
<div class="ui required inline grid field">
<label class="three wide column">Contributors</label>
<textarea class="eleven wide column" rows="2" name="contributors" style="font-family: Lato,'Helvetica Neue',Arial,Helvetica,sans-serif;">{{ contributors }}</textarea>
@ -133,6 +152,17 @@
}
}
});
$('#cal_event_dt').calendar({
type: 'datetime',
formatter: {
date: function(date, settings) {
return date.getFullYear() + '-' + leftpad(date.getMonth() + 1) + '-' + leftpad(date.getDate());
},
time: function(date, settings, forCalendar) {
return leftpad(date.getHours()) + ':' + leftpad(date.getMinutes());
}
}
});
$('#expense_no_emergency_fund').change(function() {
if ($('#expense_no_emergency_fund').prop('checked')) {

View File

@ -45,6 +45,14 @@
<td>Due date</td>
<td>{{ revision.date or '' }}</td>
</tr>
<tr>
<td>Event details</td>
<td>
{% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %}
{% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %}
{% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %}
</td>
</tr>
<tr>
<td>Contributors</td>
<td>

View File

@ -81,6 +81,14 @@
<td>Due date</td>
<td>{{ revision.date or '' }}</td>
</tr>
<tr>
<td>Event details</td>
<td>
{% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %}
{% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %}
{% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %}
</td>
</tr>
<tr>
<td>Contributors</td>
<td>

View File

@ -65,6 +65,9 @@ class BudgetRevision(models.Model):
author = models.ForeignKey(User, on_delete=models.PROTECT, related_name='+')
time = models.DateTimeField()
event_dt = models.DateTimeField(null=True)
event_attendees = models.IntegerField(null=True)
state = models.IntegerField(choices=[(v.value, v.description) for v in BudgetState])
revenue = JSONField(default=[])

View File

@ -93,6 +93,9 @@ def revision_from_form(budget, revision, form):
revision.name = form['name']
revision.date = form['date'] if form['date'] else None
revision.event_dt = form['event_dt'] if form['event_dt'] else None
revision.event_attendees = form['event_attendees'] if form['event_attendees'] else None
revision.comments = form['comments']
revision.revenue = json.loads(form['revenue'])
revision.revenue_comments = form['revenue_comments']