From ccfdfa1ba577fa87a0ce0b16a428503a917a7c88 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Wed, 23 Aug 2017 03:04:33 +0200 Subject: [PATCH] unfuck name fuck, well done swedes --- src/villages/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/villages/views.py b/src/villages/views.py index 81464aa9..5f9ad944 100644 --- a/src/villages/views.py +++ b/src/villages/views.py @@ -32,6 +32,8 @@ class VillageCreateView(CampViewMixin, LoginRequiredMixin, EnsureWritableCampMix village = form.save(commit=False) village.contact = self.request.user village.camp = Camp.objects.get(slug=self.request.session['campslug']) + if not village.name: + village.name = "noname" village.save() return HttpResponseRedirect(village.get_absolute_url()) @@ -59,6 +61,12 @@ class VillageUpdateView(CampViewMixin, EnsureUserOwnsVillageMixin, LoginRequired template_name = 'village_form.html' fields = ['name', 'description', 'private'] + def form_valid(self, form): + village = form.save(commit=False) + if not village.name: + village.name = "noname" + return HttpResponseRedirect(village.get_absolute_url()) + def get_success_url(self): return self.get_object().get_absolute_url()