Beispiel #1
0
 def handle(self, *args, **kwargs):
     if len(args) != 2:
         raise CommandError("Enter action {add|del} and username")
     action, username = args
     assert action in ('add', 'del')
     user = util.get_user_model().objects.get(**{util.get_username_field(): username})
     forums = Forum.objects.all()
     for forum in forums:
         forum.moderators.remove(user)
         if action == 'add':
             forum.moderators.add(user)
Beispiel #2
0
 def handle(self, *args, **kwargs):
     if len(args) != 2:
         raise CommandError("Enter action {add|del} and username")
     action, username = args
     assert action in ("add", "del")
     user = util.get_user_model().objects.get(**{util.get_username_field(): username})
     forums = Forum.objects.all()
     for forum in forums:
         forum.moderators.remove(user)
         if action == "add":
             forum.moderators.add(user)
Beispiel #3
0
        def querystring(self):
            return 'page=%s' % self

    Page.pages = lambda self: [
        PageRepr(i) for i in range(1, self.paginator.num_pages + 1)
    ]

from pybb.models import Category, Forum, Topic, Post, TopicReadTracker, ForumReadTracker, PollAnswerUser
from pybb.forms import PostForm, AdminPostForm, AttachmentFormSet, PollAnswerFormSet, PollForm
from pybb.templatetags.pybb_tags import pybb_topic_poll_not_voted
from pybb import defaults

from pybb.permissions import perms

from pybb import util
User = util.get_user_model()
username_field = util.get_username_field()


class RedirectToLoginMixin(object):
    """ mixin which redirects to settings.LOGIN_URL if the view encounters an PermissionDenied exception
        and the user is not authenticated. Views inheriting from this need to implement
        get_login_redirect_url(), which returns the URL to redirect to after login (parameter "next")
    """
    def dispatch(self, request, *args, **kwargs):
        try:
            return super(RedirectToLoginMixin,
                         self).dispatch(request, *args, **kwargs)
        except PermissionDenied:
            if not request.user.is_authenticated():
                from django.contrib.auth.views import redirect_to_login
Beispiel #4
0
from pybb.profiles import PybbProfile
from pybb.subscription import notify_topic_subscribers

from django.db import models, transaction
from django.core.urlresolvers import reverse
from django.db.utils import IntegrityError
from django.utils.encoding import python_2_unicode_compatible
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from django.utils.timezone import now as tznow

from annoying.fields import AutoOneToOneField

from pybb.util import unescape, get_user_model, get_username_field, get_pybb_profile_model, get_pybb_profile, get_file_path

User = get_user_model()
username_field = get_username_field()

try:
    from hashlib import sha1
except ImportError:
    from sha import sha as sha1

try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^annoying\.fields\.JSONField"])
    add_introspection_rules([], ["^annoying\.fields\.AutoOneToOneField"])
except ImportError:
    pass

from pybb import defaults
Beispiel #5
0
    from django.core.paginator import Paginator, Page
    class PageRepr(int):
        def querystring(self):
            return 'page=%s' % self
    Page.pages = lambda self: [PageRepr(i) for i in range(1, self.paginator.num_pages + 1)]
    pure_pagination = False

from pybb.models import Category, Forum, Topic, Post, TopicReadTracker, ForumReadTracker, PollAnswerUser
from pybb.forms import PostForm, AdminPostForm, AttachmentFormSet, PollAnswerFormSet, PollForm
from pybb.templatetags.pybb_tags import pybb_topic_poll_not_voted
from pybb import defaults

from pybb.permissions import perms

from pybb import util
User = util.get_user_model()
username_field = util.get_username_field()


class PaginatorMixin(object):
    def get_paginator(self, queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs):
        kwargs = {}
        if pure_pagination:
            kwargs['request'] = self.request
        return Paginator(queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs)


class RedirectToLoginMixin(object):
    """ mixin which redirects to settings.LOGIN_URL if the view encounters an PermissionDenied exception
        and the user is not authenticated. Views inheriting from this need to implement
        get_login_redirect_url(), which returns the URL to redirect to after login (parameter "next")
Beispiel #6
0
from django.db import models, transaction
from django.core.urlresolvers import reverse
from django.db.utils import IntegrityError
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django.utils.timezone import now as tznow

from annoying.fields import AutoOneToOneField
try:
    from sorl.thumbnail import ImageField
except ImportError:
    from django.db.models import ImageField
from pybb.util import unescape, get_user_model, get_username_field

User = get_user_model()
username_field = get_username_field()

try:
    from hashlib import sha1
except ImportError:
    from sha import sha as sha1

try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^annoying\.fields\.JSONField"])
    add_introspection_rules([], ["^annoying\.fields\.AutoOneToOneField"])
except ImportError:
    pass

from pybb import defaults
Beispiel #7
0
from django.db import models, transaction
from django.core.urlresolvers import reverse
from django.db.utils import IntegrityError
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from django.utils.timezone import now as tznow

from annoying.fields import AutoOneToOneField
try:
    from sorl.thumbnail import ImageField
except ImportError:
    from django.db.models import ImageField
from pybb.util import unescape, get_user_model, get_username_field

User = get_user_model()
username_field = get_username_field()

try:
    from hashlib import sha1
except ImportError:
    from sha import sha as sha1

try:
    from south.modelsinspector import add_introspection_rules
    add_introspection_rules([], ["^annoying\.fields\.JSONField"])
    add_introspection_rules([], ["^annoying\.fields\.AutoOneToOneField"])
except ImportError:
    pass

from pybb import defaults