Use named_id prefix "A-" for assets
This commit is contained in:
parent
6aadef827e
commit
0554f6427c
|
@ -11,6 +11,8 @@ class AssetCreateView(CreateView):
|
|||
fields = ['named_id', 'description', 'quantity']
|
||||
|
||||
def form_valid(self, form):
|
||||
if not form.instance.named_id.startswith('A-'):
|
||||
form.instance.named_id = 'A-' + form.instance.named_id
|
||||
form.instance.changed_by = self.request.user
|
||||
form.instance.created_by = self.request.user
|
||||
return super().form_valid(form)
|
||||
|
@ -19,8 +21,11 @@ class AssetCreateView(CreateView):
|
|||
class AssetUpdateView(UpdateView):
|
||||
model = Asset
|
||||
fields = ['named_id', 'description', 'quantity']
|
||||
success_url = '/asset/'
|
||||
|
||||
def form_valid(self, form):
|
||||
if not form.instance.named_id.startswith('A-'):
|
||||
form.instance.named_id = 'A-' + form.instance.named_id
|
||||
form.instance.changed_by = self.request.user
|
||||
return super().form_valid(form)
|
||||
|
||||
|
|
Loading…
Reference in New Issue