Exemplo n.º 1
0
 def get_target(self, mail):
     """
     gets the link target by evaluating the string using the email content
     """
     from pennyrev.models import Newsletter
     if self.identifier != '':
         return Newsletter.get_view_link(self.identifier)
     template = Template(self.link_target)
     return template.render(Context(mail.get_context()))
Exemplo n.º 2
0
 def render(self, context):
     from pennyrev.models import Link, Newsletter
     if 'mail' not in context:
         return u'#'
     mail = context['mail']
     newsletter = mail.job.newsletter
     if newsletter.is_workflow():
         job = newsletter.get_default_job()
     else:
         job = mail.job
     try:
         link = job.links.get(identifier=self.identifier)
     except job.links.model.DoesNotExist:
         link = Newsletter.add_view_link_to_job(self.identifier, job)
     return context['base_url'] + reverse('pennyrev.redirect_link', args=(mail.mail_hash, link.link_hash))
Exemplo n.º 3
0
 def test_is_valid(self):
     n = Newsletter()
     self.assertFalse(n.is_valid(), "Empty Newsletter can not be valid.")
     n.subject = 'some text'
     self.assertTrue(n.is_valid(), "Newsletter should be valid now.")
Exemplo n.º 4
0
    def __unicode__(self):
        return self.name
    
    @property
    def member_count(self):
        return self.subscribers.active().count()
    
    def get_member_count(self):
        return self.member_count
    get_member_count.short_description = "Member Count"
    
    def get_newsletter_receiver_collections(self):
        """
        Every Group has only one collection
        """
        return (('all',{}),)
    
    def get_receiver_queryset(self):
        """
        Return all group members
        """
        return self.subscribers.active()
    
class SubscriberGroupAdmin(JobUnitAdmin):
    list_display = ('__unicode__', 'get_member_count')

# register view links
from pennyrev.models import Newsletter
from pennyrev.module.subscriber.views import unsubscribe
Newsletter.register_view_link('subscriber.unsubscribe',unsubscribe)