Started work on improving asset form update and validation - requires de-spaghettifying of asset_update.html before continuing

This commit is contained in:
Matthew Smith
2019-10-05 01:44:54 +01:00
parent 5bfa737f6b
commit 769137fabd
5 changed files with 50 additions and 75 deletions

View File

@@ -53,8 +53,10 @@ class AssetDetail(LoginRequiredMixin, generic.DetailView):
# template_name = 'asset_update.html'
# # success_url = reverse_lazy('asset_list')
class AssetEdit(LoginRequiredMixin, generic.TemplateView):
class AssetEdit(LoginRequiredMixin, generic.UpdateView):
template_name = 'asset_update.html'
model = models.Asset
form_class = forms.AssetForm
def get_context_data(self, **kwargs):
context = super(AssetEdit, self).get_context_data(**kwargs)
@@ -75,6 +77,19 @@ class AssetEdit(LoginRequiredMixin, generic.TemplateView):
return context
def get_success_url(self):
return reverse("asset_detail", kwargs={"pk":self.object.id})
class AssetCreate(LoginRequiredMixin, generic.CreateView):
template_name = 'asset_update.html'
model = models.Asset
form_class = forms.AssetForm
def get_context_data(self, **kwargs):
context = super(AssetCreate, self).get_context_data(**kwargs)
context["create"] = True
return context
@login_required()
def asset_update(request):
context = dict()