Exemplo n.º 1
0
 def form_valid(self, form):
     self.object = form.save(commit=False)
     self.object.owner = self.request.user
     try:
         self.object.save()
     except IntegrityError:
         message_utils.add_error_message(self.request.session, _('You already have a phone with this label.'))
         return HttpResponseRedirect(reverse_lazy('phone:create_phone'))
     return super(ModelFormMixin, self).form_valid(form)
Exemplo n.º 2
0
 def form_valid(self, form):
     try:
         return super().form_valid(form)
     except IntegrityError:
         message_utils.add_error_message(
             self.request.session,
             _('You already created a power socket with this parameters.'))
         return HttpResponseRedirect(
             reverse_lazy('phone:update_power_socket',
                          args=[self.kwargs.get(self.pk_url_kwarg)]))
Exemplo n.º 3
0
 def form_valid(self, form):
     try:
         return super().form_valid(form)
     except IntegrityError:
         message_utils.add_error_message(
             self.request.session,
             _('You already have a sim with this label.'))
         return HttpResponseRedirect(
             reverse_lazy('phone:update_sim',
                          args=[self.kwargs.get(self.pk_url_kwarg)]))