コード例 #1
0
ファイル: views.py プロジェクト: jungepiraten/jupicp
 def get_context_data(self, **kwargs):
     context = super(MailinglistsListView, self).get_context_data(**kwargs)
     lists = {}
     for listname, mlist in mailman.get_lists(only_public=True, lock=False):
         if mlist.host_name not in lists:
             lists[mlist.host_name] = {}
         lists[mlist.host_name][listname] = mlist
     context['lists'] = lists
     if self.request.user:
         context['mails'] = self.request.user.get_mails(only_verified=True)
     return context
コード例 #2
0
ファイル: views.py プロジェクト: jungepiraten/jupicp
    def post(self, request, **kwargs):
        for listname, mlist in mailman.get_lists(only_public=True, lock=False):
            subscribe = set()
            if "subscription_" + listname in self.request.POST and self.request.POST["subscription_" + listname]:
                subscribe.add(self.request.POST["subscription_" + listname])
            mails = [mail["mail"] for mail in self.request.user.get_mails(only_verified=True)]
            subscribed = set(mlist.members) & set(mails)

            members_remove = subscribed - subscribe
            members_add = subscribe - subscribed

            if len(members_remove | members_add) > 0:
                mlist.Lock()
                for member in members_remove:
                    mlist.ApprovedDeleteMember(member, whence="JuPiCP", admin_notif=False, userack=False)
                for member in subscribe - subscribed:
                    mlist.ApprovedAddMember(mailman.UserDesc(address=member), admin_notif=False, ack=False)
                mlist.Save()
                mlist.Unlock()

        return HttpResponseRedirect(reverse_lazy("lists"))