quick comment feature for reports and stuff
This commit is contained in:
parent
b19c001ad1
commit
6a91631f9b
6 changed files with 131 additions and 7 deletions
|
@ -1,7 +1,9 @@
|
|||
from django.db import transaction
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.mapdata.forms import I18nModelFormMixin
|
||||
from c3nav.mapdata.models.report import Report
|
||||
from c3nav.mapdata.models.report import Report, ReportUpdate
|
||||
|
||||
|
||||
class ReportIssueForm(I18nModelFormMixin, ModelForm):
|
||||
|
@ -18,3 +20,29 @@ class ReportMissingLocationForm(I18nModelFormMixin, ModelForm):
|
|||
class Meta:
|
||||
model = Report
|
||||
fields = ['title', 'description', 'created_title', 'created_groups']
|
||||
|
||||
|
||||
class ReportUpdateForm(ModelForm):
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.request = request
|
||||
self.fields['open'].label = _('change status')
|
||||
self.fields['open'].widget.choices = (
|
||||
('unknown', _('don\'t change')),
|
||||
('true', _('open')),
|
||||
('false', _('closed')),
|
||||
)
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
super().save()
|
||||
report = self.instance.report
|
||||
if self.instance.open is not None:
|
||||
report.open = self.instance.open
|
||||
if self.instance.assigned_to:
|
||||
report.assigned_to = self.instance.assigned_to
|
||||
report.save()
|
||||
|
||||
class Meta:
|
||||
model = ReportUpdate
|
||||
fields = ['open', 'comment', 'public']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue