Renamed the templates of the transactions in the accounting application.

This commit is contained in:
依瑪貓 2020-08-17 20:51:47 +08:00
parent 5e321ad420
commit c3fc2a5093
9 changed files with 7 additions and 6 deletions

View File

@ -220,7 +220,8 @@ class Transaction(DirtyFieldsMixin, models.Model):
self.created_by = self.current_user self.created_by = self.current_user
if self.current_user is not None: if self.current_user is not None:
self.updated_by = self.current_user self.updated_by = self.current_user
to_save = [x for x in self.records if x.is_dirty()] to_save = [x for x in self.records
if x.is_dirty(check_relationship=True)]
for record in to_save: for record in to_save:
if record.pk is None: if record.pk is None:
record.pk = new_pk(Record) record.pk = new_pk(Record)

View File

@ -806,8 +806,9 @@ class TransactionView(DetailView):
return self.kwargs["txn"] return self.kwargs["txn"]
def get_template_names(self): def get_template_names(self):
return ["accounting/transaction_detail-%s.html" model_name = self.get_object().__class__.__name__.lower()
% (self.kwargs["txn_type"],)] txn_type = self.kwargs["txn_type"]
return [F"accounting/{model_name}_{txn_type}_detail.html"]
@method_decorator(login_required, name="dispatch") @method_decorator(login_required, name="dispatch")
@ -827,9 +828,8 @@ class TransactionFormView(FormView):
def get_template_name(self) -> str: def get_template_name(self) -> str:
"""Returns the name of the template.""" """Returns the name of the template."""
namespace = self.request.resolver_match.namespace
model_name = self.model.__name__.lower() model_name = self.model.__name__.lower()
return F"{namespace}/{model_name}_form-{self.txn_type}.html" return F"accounting/{model_name}_{self.txn_type}_form.html"
def _get_new_record_template_json(self) -> str: def _get_new_record_template_json(self) -> str:
context = {"record_type": "TTT", "no": "NNN"} context = {"record_type": "TTT", "no": "NNN"}
@ -883,7 +883,7 @@ class TransactionDeleteView(DeleteView):
@method_decorator(login_required, name="dispatch") @method_decorator(login_required, name="dispatch")
class TransactionSortFormView(FormView): class TransactionSortFormView(FormView):
"""The form to sort the transactions in a same day.""" """The form to sort the transactions in a same day."""
template_name = "accounting/transaction-sort.html" template_name = "accounting/transaction_sort_form.html"
form_class = TransactionSortForm form_class = TransactionSortForm
not_modified_message = gettext_noop( not_modified_message = gettext_noop(
"The transaction orders were not modified.") "The transaction orders were not modified.")