diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-05-11 02:32:21 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-05-11 02:32:21 +0200 |
commit | 6a39197fed921723d03aa5655a1bee7d044353c0 (patch) | |
tree | a8fc995a03e1392ae1da9580214e32848921cf5d | |
parent | 1d1844ec02a698494ba943bde8d5f04571f08b4f (diff) | |
download | Ishtar-6a39197fed921723d03aa5655a1bee7d044353c0.tar.bz2 Ishtar-6a39197fed921723d03aa5655a1bee7d044353c0.zip |
Operation closing (closes #441)
-rw-r--r-- | ishtar/furnitures/forms.py | 12 | ||||
-rw-r--r-- | ishtar/furnitures/models.py | 14 | ||||
-rw-r--r-- | ishtar/templates/sheet_operation.html | 2 | ||||
-rw-r--r-- | static/media/style.css | 4 |
4 files changed, 22 insertions, 10 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py index e9a9159eb..bb6555547 100644 --- a/ishtar/furnitures/forms.py +++ b/ishtar/furnitures/forms.py @@ -1227,6 +1227,16 @@ class FileClosingWizard(DeletionWizard): datas[0][1].append(res[field]) return datas + def done(self, request, storage, form_list, **kwargs): + obj = self.get_current_object(request, storage) + for form in form_list: + if form.is_valid(): + if 'end_date' in form.cleaned_data and hasattr(obj, 'end_date'): + obj.end_date = form.cleaned_data['end_date'] + obj.save() + return render_to_response('wizard_done.html', {}, + context_instance=RequestContext(request)) + class FileDeletionWizard(FileClosingWizard): def get_formated_datas(self, forms): datas = super(FileDeletionWizard, self).get_formated_datas(forms) @@ -1790,7 +1800,7 @@ class OperationDateFormSelection(forms.Form): end_date = forms.DateField(label=_(u"Closing date"), widget=widgets.JQueryDate) -class OperationClosingWizard(DeletionWizard): +class OperationClosingWizard(FileClosingWizard): model = models.Operation fields = ['year', 'operation_code', 'operation_type', 'associated_file', 'in_charge', 'start_date', 'end_date', 'comment', 'towns', 'remains'] diff --git a/ishtar/furnitures/models.py b/ishtar/furnitures/models.py index 9bbb8bf2d..db8773ad4 100644 --- a/ishtar/furnitures/models.py +++ b/ishtar/furnitures/models.py @@ -590,16 +590,18 @@ class Operation(BaseHistorizedItem, OwnPerms): return Q(in_charge=user.person)|Q(history_modifier=user)\ & Q(end_date__isnull=True) - """ + def is_active(self): + return not bool(self.end_date) + def closing(self): - if self.is_active: + if self.is_active(): return for item in self.history.all(): - if item.is_active(): + if not item.end_date: break - closing_item = item - return {'date':item.history_date, 'user':item.history_modifier} -""" + return {'date':item.history_date, + 'user':IshtarUser.objects.get(pk=item.history_modifier_id)} + class Parcel(LightHistorizedItem): associated_file = models.ForeignKey(File, related_name='parcels', blank=True, null=True, verbose_name=_(u"File")) diff --git a/ishtar/templates/sheet_operation.html b/ishtar/templates/sheet_operation.html index 41ae6f9ab..9f2a711d9 100644 --- a/ishtar/templates/sheet_operation.html +++ b/ishtar/templates/sheet_operation.html @@ -14,7 +14,7 @@ <p><label>{%trans "Edition date:"%}</label> <span class='value'>{{ item.history.all.0.history_date }}</span></p> <!-- date = now --> <p><label>{%trans "Begining date:"%}</label> <span class='value'>{{ item.start_date }}</span></p> -<p><label>{%trans "Field work end date:"%}</label> <span class='value'>{{ item.end_date }}</span></p> +<p><label>{%trans "Field work end date:"%}</label> <span class='value'>{{ item.end_date|default:"-" }}</span></p> <p><label>{%trans "Head scientist:"%}</label> <span class='value'>{{ item.in_charge.full_label }}</span></p> <p><label>{%trans "State:"%}</label> <span class='value'>{% if item.is_active %}{%trans "Active file"%}</span></p> diff --git a/static/media/style.css b/static/media/style.css index d4168d5ba..b4136f6a4 100644 --- a/static/media/style.css +++ b/static/media/style.css @@ -327,12 +327,12 @@ table.confirm tr.spacer td:last-child{ #window label{ display:inline-table; font-weight:bold; - width:240px; + width:245px; } #window span.value{ display:inline-table; - width:470px; + width:465px; } #window p{ |