Added asset_id autofill for asset creation and duplication

This commit is contained in:
Matthew Smith
2019-10-14 15:50:05 +01:00
parent 64439ff53b
commit 8ec27eb075
2 changed files with 22 additions and 2 deletions

View File

@@ -89,12 +89,16 @@ class AssetCreate(LoginRequiredMixin, generic.CreateView):
def get_context_data(self, **kwargs):
context = super(AssetCreate, self).get_context_data(**kwargs)
context["create"] = True
context["connectors"] = models.Connector.objects.all()
return context
def get_initial(self, *args, **kwargs):
initial = super().get_initial(*args, **kwargs)
initial["asset_id"] = models.Asset.get_available_asset_id()
return initial
def get_success_url(self):
return reverse("asset_detail", kwargs={"pk": self.object.id})