示例#1
0
 def form_valid(self, form):
     r = super(MailCreate, self).form_valid(form)
     for recipient in form.cleaned_data["default_recipients"]:
         if recipient[0] == "g":
             obj = get_object_or_404(Group, pk=recipient[1:])
         else:
             obj = get_object_or_404(Lageruser, pk=recipient[1:])
         recipient = MailTemplateRecipient(content_object=obj)
         recipient.mailtemplate = self.object
         recipient.save()
     return r
示例#2
0
文件: views.py 项目: MPIB/Lagerregal
 def form_valid(self, form):
     r = super(MailCreate, self).form_valid(form)
     for recipient in form.cleaned_data["default_recipients"]:
         if recipient[0] == "g":
             obj = get_object_or_404(Group, pk=recipient[1:])
         else:
             obj = get_object_or_404(Lageruser, pk=recipient[1:])
         recipient = MailTemplateRecipient(content_object=obj)
         recipient.mailtemplate = self.object
         recipient.save()
     return r
示例#3
0
文件: views.py 项目: MPIB/Lagerregal
 def form_valid(self, form):
     r = super(MailUpdate, self).form_valid(form)
     for recipient in self.object.default_recipients.all():
         identifier = recipient.content_type.name[0].lower() + str(recipient.id)
         if identifier not in form.cleaned_data["default_recipients"]:
             recipient.delete()
         else:
             form.cleaned_data["default_recipients"].remove(identifier)
     for recipient in form.cleaned_data["default_recipients"]:
         if recipient[0] == "g":
             obj = get_object_or_404(Group, pk=recipient[1:])
         else:
             obj = get_object_or_404(Lageruser, pk=recipient[1:])
         rec = MailTemplateRecipient(content_object=obj)
         rec.mailtemplate = self.object
         rec.save()
     return r
示例#4
0
 def form_valid(self, form):
     r = super(MailUpdate, self).form_valid(form)
     for recipient in self.object.default_recipients.all():
         identifier = recipient.content_type.name[0].lower() + str(
             recipient.id)
         if identifier not in form.cleaned_data["default_recipients"]:
             recipient.delete()
         else:
             form.cleaned_data["default_recipients"].remove(identifier)
     for recipient in form.cleaned_data["default_recipients"]:
         if recipient[0] == "g":
             obj = get_object_or_404(Group, pk=recipient[1:])
         else:
             obj = get_object_or_404(Lageruser, pk=recipient[1:])
         rec = MailTemplateRecipient(content_object=obj)
         rec.mailtemplate = self.object
         rec.save()
     return r