mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 04:49:25 +00:00
Some templating and migration fix
This commit is contained in:
@ -202,7 +202,6 @@ class OperationForm(forms.ModelForm):
|
||||
'target_id': HiddenInput,
|
||||
'date': SelectDate,
|
||||
'invoice': SelectFile,
|
||||
'target_type': forms.RadioSelect,
|
||||
}
|
||||
user = AutoCompleteSelectField('users', help_text=None, required=False)
|
||||
club_account = AutoCompleteSelectField('club_accounts', help_text=None, required=False)
|
||||
@ -272,11 +271,18 @@ class OperationCreateView(CanCreateMixin, CreateView):
|
||||
def get_initial(self):
|
||||
ret = super(OperationCreateView, self).get_initial()
|
||||
if 'parent' in self.request.GET.keys():
|
||||
obj = GeneralJournal.objects.filter(id=int(self.request.GET['parent'])).first()
|
||||
if obj is not None:
|
||||
ret['journal'] = obj.id
|
||||
self.journal = GeneralJournal.objects.filter(id=int(self.request.GET['parent'])).first()
|
||||
if self.journal is not None:
|
||||
ret['journal'] = self.journal.id
|
||||
return ret
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
""" Add journal to the context """
|
||||
kwargs = super(OperationCreateView, self).get_context_data(**kwargs)
|
||||
if self.journal:
|
||||
kwargs['object'] = self.journal
|
||||
return kwargs
|
||||
|
||||
class OperationEditView(CanEditMixin, UpdateView):
|
||||
"""
|
||||
An edit view, working as detail for the moment
|
||||
@ -286,6 +292,12 @@ class OperationEditView(CanEditMixin, UpdateView):
|
||||
form_class = OperationForm
|
||||
template_name = 'accounting/operation_edit.jinja'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
""" Add journal to the context """
|
||||
kwargs = super(OperationCreateView, self).get_context_data(**kwargs)
|
||||
kwargs['object'] = self.object.journal
|
||||
return kwargs
|
||||
|
||||
# Company views
|
||||
|
||||
class CompanyCreateView(CanCreateMixin, CreateView):
|
||||
|
Reference in New Issue
Block a user