Exemple #1
0
def get_email_message(user, **kwargs):
    try:
        validate_email(user.email)
    except:
        # Invalid email
        return

    if user.email == '*****@*****.**' % getattr(user, compat.get_username_field()):
        return

    lang = util.get_pybb_profile(user).language or settings.LANGUAGE_CODE
    translation.activate(lang)

    message = render_to_string('pybb/mail_templates/subscription_email_body.html',
                               kwargs)
    return message
def get_email_message(user, **kwargs):
    try:
        validate_email(user.email)
    except:
        # Invalid email
        return

    if user.email == '*****@*****.**' % getattr(user, compat.get_username_field()):
        return

    lang = util.get_pybb_profile(user).language or settings.LANGUAGE_CODE
    translation.activate(lang)

    message = render_to_string('pybb/mail_templates/subscription_email_body.html',
                               kwargs)
    return message
Exemple #3
0
def notify_topic_subscribers(post):
    topic = post.topic
    if post != topic.head:
        old_lang = translation.get_language()

        # Define constants for templates rendering
        delete_url = reverse('pybb:delete_subscription', args=[post.topic.id])
        current_site = Site.objects.get_current()
        site_url = get_setting('site', 'global', 'siteurl')
        from_email = settings.DEFAULT_FROM_EMAIL

        subject = render_to_string('pybb/mail_templates/subscription_email_subject.html',
                                   {'site': current_site,
                                    'site_url': site_url,
                                    'post': post})
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())

        mails = tuple()
        for user in topic.subscribers.exclude(pk=post.user.pk):
            try:
                validate_email(user.email)
            except:
                # Invalid email
                continue

            if user.email == '*****@*****.**' % getattr(user, compat.get_username_field()):
                continue

            lang = util.get_pybb_profile(user).language or settings.LANGUAGE_CODE
            translation.activate(lang)

            message = render_to_string('pybb/mail_templates/subscription_email_body.html',
                                       {'site': current_site,
                                        'site_url': site_url,
                                        'post': post,
                                        'delete_url': delete_url,
                                        'user': user})
            mails += ((subject, message, from_email, [user.email]),)

        # Send mails
        send_mass_mail(mails, fail_silently=True)

        # Reactivate previous language
        translation.activate(old_lang)
Exemple #4
0
# -*- coding: utf-8
from __future__ import unicode_literals
from datetime import datetime
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
from django.core.urlresolvers import reverse
from tendenci.apps.perms.utils import update_perms_and_save

from .models import Category, Forum, Topic, Post, Profile, Attachment, PollAnswer
from .forms import CategoryAdminForm

import compat, util
username_field = compat.get_username_field()


class ForumInlineAdmin(admin.TabularInline):
    model = Forum
    fields = ['name', 'hidden', 'position']
    extra = 0


class CategoryAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('name',)}
    list_display = ['id', 'name', 'position', 'hidden', 'forum_count']
    list_display_links = ('name',)
    list_per_page = 20
    ordering = ['position']
    search_fields = ['name']
    list_editable = ['position']
    fieldsets = (
        (None, {'fields': ('name', 'position', 'slug', 'status_detail')}),
Exemple #5
0
 def get_absolute_url(self):
     return reverse("pybb:user", kwargs={"username": getattr(self.user, get_username_field())})
Exemple #6
0
 def get_absolute_url(self):
     return reverse(
         'pybb:user',
         kwargs={'username': getattr(self.user, get_username_field())})
Exemple #7
0
 def get_absolute_url(self):
     return reverse('pybb:user', kwargs={'username': getattr(self.user, get_username_field())})