Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specification of admin sub-urls #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions django_mailman/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.utils.translation import ugettext_lazy as _

from webcall import MultipartPostHandler
from django.conf import settings

# Mailman-Messages for a successfull subscription
SUBSCRIBE_MSG = (
Expand Down Expand Up @@ -105,6 +106,8 @@ class List(models.Model):
password = models.CharField(max_length=50)
email = models.EmailField(unique=True)
main_url = models.URLField(verify_exists=False)
admin_url_part = models.CharField(max_length=20, default='admin')
admindb_url_part = models.CharField(max_length=20, default='admindb')
encoding = models.CharField(max_length=20, choices=LANGUAGES)

class Meta:
Expand Down Expand Up @@ -157,13 +160,13 @@ def __parse_member_content(self, content, encoding='iso-8859-1'):
return (letters, members, chunks)

def get_admin_moderation_url(self):
return '%s/admindb/%s/?adminpw=%s' % (self.main_url, self.name,
return '%s/%s/%s/?adminpw=%s' % (self.main_url, self.admindb_url_part, self.name,
self.password)

def subscribe(self, email, first_name=u'', last_name=u'', send_welcome_msg=False):
from email.Utils import formataddr

url = '%s/admin/%s/members/add' % (self.main_url, self.name)
url = '%s/%s/%s/members/add' % (self.main_url, self.admin_url_part, self.name)

first_name = check_encoding(first_name, self.encoding)
last_name = check_encoding(last_name, self.encoding)
Expand All @@ -182,7 +185,7 @@ def subscribe(self, email, first_name=u'', last_name=u'', send_welcome_msg=False
raise Exception(error.encode(self.encoding))

def unsubscribe(self, email):
url = '%s/admin/%s/members/remove' % (self.main_url, self.name)
url = '%s/%s/%s/members/remove' % (self.main_url, self.admin_url_part, self.name)

email = check_encoding(email, self.encoding)
UNSUBSCRIBE_DATA['adminpw'] = self.password
Expand All @@ -196,7 +199,7 @@ def unsubscribe(self, email):
raise Exception(error.encode(self.encoding))

def get_all_members(self):
url = '%s/admin/%s/members/list' % (self.main_url, self.name)
url = '%s/%s/%s/members/list' % (self.main_url, self.admin_url_part, self.name)
data = { 'adminpw': self.password }
opener = urllib2.build_opener(MultipartPostHandler(self.encoding))

Expand Down