Container use prefix "C-" for named_id
This commit is contained in:
parent
5cf49b7d47
commit
056317a340
|
@ -27,6 +27,8 @@ class ContainerCreateView(LoginRequiredMixin, generic.CreateView):
|
|||
fields = ['named_id', 'description', 'color', 'container_type']
|
||||
|
||||
def form_valid(self, form):
|
||||
if not form.instance.named_id.startswith('C-'):
|
||||
form.instance.named_id = 'C-' + form.instance.named_id
|
||||
form.instance.changed_by = self.request.user
|
||||
form.instance.created_by = self.request.user
|
||||
return super().form_valid(form)
|
||||
|
@ -53,8 +55,11 @@ class ContainerUpdateView(LoginRequiredMixin, generic.UpdateView):
|
|||
model = Container
|
||||
# template_name = 'container/detail.html'
|
||||
fields = ['named_id', 'description', 'color', 'container_type']
|
||||
success_url = "/container/"
|
||||
|
||||
def form_valid(self, form):
|
||||
if not form.instance.named_id.startswith('C-'):
|
||||
form.instance.named_id = 'C-' + form.instance.named_id
|
||||
form.instance.changed_by = self.request.user
|
||||
return super().form_valid(form)
|
||||
|
||||
|
|
Loading…
Reference in New Issue