def save(self, *args, **kwargs): super(Post, self).save(*args, **kwargs) if not self.notified: if self.status > 1 and self.publish and self.publish <= datetime.datetime.now(): if self.group: group_notify(self) self.notified = True super(Post, self).save(*args, **kwargs)
def save(self, *args, **kwargs): super(Post, self).save(*args, **kwargs) if not self.notified: if self.status > 1 and self.publish and self.publish <= datetime.datetime.now( ): if self.group: group_notify(self) self.notified = True super(Post, self).save(*args, **kwargs)
def join(request, object_id): group = get_object_or_404(CTGroup, pk=object_id) u = request.user form = memb = None try: memb = GroupMembership.objects.get(user=u, group=group) except GroupMembership.DoesNotExist: # moderate_membership = 'open', 'mod', 'closed' if not group.is_closed: mod = None if group.moderate_membership == "mod": if request.method == "POST": if request.POST["result"] == _("Cancel"): return HttpResponseRedirect(reverse("group", kwargs={"group_slug": group.slug})) form = GroupJoinForm(request.POST) if form.is_valid(): mod = Moderation(status="pending", applicants_text=form.cleaned_data["reason_for_joining"]) mod.save() memb = GroupMembership(user=u, group=group, moderation=mod) memb.save() group_notify(mod, True) return HttpResponseRedirect(reverse("join-group", kwargs={"object_id": group.id})) # else, reshow form else: mod = None else: # a GET, so make form form = GroupJoinForm() else: memb = GroupMembership(user=u, group=group, moderation=mod) memb.save() return render_to_response( "ct_groups/ct_groups_confirm_join.html", RequestContext(request, {"group": group, "memb": memb, "form": form}) )