示例#1
0
    def get_mail(self, feedback, realhost=None):
        """
        Return mail
        """

        try:
            from_email = self.from_email
        except:
            from_email = settings.DEFAULT_FROM_EMAIL

        if self.auto_signup:
            Profile = utils.get_custom_model_class(
                pf_defaults.CUSTOM_USER_MODEL)
            Profile.objects.create_inactive_user(feedback.email,
                                                 realhost=realhost)

        mail = EmailMultiAlternatives(self.email_subject,
                                      self.get_text_email(feedback),
                                      from_email, [feedback.email],
                                      headers={'format': 'flowed'})

        html_email = self.get_html_email(feedback)
        if html_email:
            mail.attach_alternative(html_email, "text/html")

        if self.has_attachments():
            for attach in self.attachments():
                if not attach.is_deleted:
                    mail.attach_file(attach.get_abs_path())

        return mail
示例#2
0
def document_list(request, list_type=None, site_domain=None):
    message = request.GET.get('message', '')

    base_url_namespace = 'document:admin:index'

    #filter_form = forms.MagazineDocumentListFilterForm(request.GET)
    accepting_filters = [
        ('search_text', ''),
        ('genre', None),
        ('year', ''),
        ('month', ''),
        ('day', ''),
    ]
    force_filter = None

    nav = NavigationFilter(request,
                           default_order='-pub_date',
                           force_filter=force_filter,
                           accepting_filters=accepting_filters)

    search_args, search_kwargs = [], {}

    #    search_args, search_kwargs, sql, message = \
    #        _get_common_doc_list(request, nav)

    #    query = lambda x: x.filter(
    #        *search_args, **search_kwargs)

    form = forms.DocumentFiltersForm(request.GET)

    if nav.search_text:
        search_args.append(
            Q(title__icontains=nav.search_text)
            | Q(body__icontains=nav.search_text))

    paginator = nav.get_queryset_with_paginator(
        get_custom_model_class(defaults.CUSTOM_DOCUMENT_MODEL),
        reverse(base_url_namespace),
        search_query=(search_args, search_kwargs),
        obj_per_page=admin_defaults.ADMIN_OBJECTS_PER_PAGE)
    objects_list = paginator.current_page.object_list
    return {
        'nav': nav,
        'list_type': list_type,
        'objects_list': objects_list,
        'paginator': paginator,
        'message': message,
        'form': form
    }
示例#3
0
    def __init__(self, service):
        self.service = service
        self.model = get_custom_model_class(self.model)

        self.urls = []
        for meta_url in self._meta_urls:
            pattern, method, name, is_public = meta_url
            if name == '__call__':
                name = service.name
            else:
                name = service.name + '-' + name

            if isinstance(method, MethodDecoratorAdaptor):
                method.func.set_instance(self)
            else:
                method.set_instance(self)
            self.urls.append((url(pattern % {'service_name': service.name},
                                  method,
                                  name=name), is_public))
示例#4
0
    def __init__(self, service):
        self.service = service
        self.model = get_custom_model_class(self.model)

        self.urls = []
        for meta_url in self._meta_urls:
            pattern, method, name, is_public = meta_url
            if name == '__call__':
                name = service.name
            else:
                name = service.name + '-' + name

            if isinstance(method, MethodDecoratorAdaptor):
                method.func.set_instance(self)
            else:
                method.set_instance(self)
            self.urls.append((
                url(pattern % {'service_name': service.name}, method,
                    name=name),
                is_public))
示例#5
0
def get_settings_from_db(model_name, field):
    return get_custom_model_class(model_name).objects.get(site__id=SITE_ID)
示例#6
0
from django import http
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from spicy.core.admin import conf, defaults as admin_defaults
from spicy.core.service import api
from spicy.core.siteskin.decorators import render_to, ajax_request
from spicy.core.siteskin.decorators import APIResponse, APIResponseFail
from spicy import utils
from spicy.utils.permissions import perm, change_perm, add_perm, delete_perm
from . import defaults, forms
from .decorators import is_staff
from .models import BlacklistedIP


Profile = utils.get_custom_model_class(defaults.CUSTOM_USER_MODEL)

admin.site.register(Profile)


class AdminApp(conf.AdminAppBase):
    name = 'profile'
    label = _('Profile')
    order_number = 10

    menu_items = (
        conf.AdminLink(
            'profile:admin:create', _('Create profile'),
            perms=add_perm(defaults.CUSTOM_USER_MODEL)),
        conf.AdminLink(
            'profile:admin:index', _('All profiles'),
示例#7
0
 class Meta:
     model = utils.get_custom_model_class(defaults.SIMPLE_PAGE_MODEL)
     fields = ('title', 'url', 'is_custom', 'template_name', 'content',
               'enable_comments', 'is_active', 'registration_required',
               'sites', 'is_sitemap')
     widgets = {'is_custom': forms.HiddenInput()}
示例#8
0
from . import defaults
from django import http
from django.template import RequestContext
from spicy.utils import get_custom_model_class
from django.shortcuts import get_object_or_404

SimplePage = get_custom_model_class(defaults.SIMPLE_PAGE_MODEL)


def render_simplepage(request, page, **kwargs):
    """
    Example of universal rubric rendering
    """
    if isinstance(page, basestring):
        page = SimplePage.objects.get(url=page)
    if page.is_active and not request.user.is_staff:
        page = get_object_or_404(SimplePage, url='/errors/404/')
    context = {'page_slug': page.title, 'page': page}
    context.update(**kwargs)
    content_type = 'text/plain' if page.url.endswith('.txt') else 'text/html'
    request.session['SIMPLEPAGE_ID'] = page.pk

    try:
        rendered_page = page.get_template().render(
            RequestContext(request, context))
    except:
        rendered_page = ''

    return http.HttpResponse(rendered_page, content_type=content_type)
示例#9
0
from . import defaults
from django import forms
from spicy.utils import get_custom_model_class

Category = get_custom_model_class(defaults.CUSTOM_CATEGORY_MODEL)


class CategoryForm(forms.ModelForm):
    class Meta:
        model = Category
        fields = 'title', 'slug', 'order_lv', 'site'
示例#10
0
from django import forms
from django.utils.translation import ugettext_lazy as _
from spicy.core.profile import defaults as pr_defaults
from spicy.utils import get_custom_model_class

Profile = get_custom_model_class(pr_defaults.CUSTOM_USER_MODEL)


class ActionsFilterForm(forms.Form):
    profile = forms.ModelChoiceField(
        label=_('User'), queryset=Profile.objects.all())
    ip = forms.CharField(
        label=_('IP address'), max_length=15,
        help_text=_('Add * to IP address to match subnetworks, i.e. 127.0.*'))
    filter_from = forms.DateTimeField(
        label=_('From date'),
        widget=forms.DateTimeInput(
            attrs={'class': 'datetime fill-up'}, format='%Y-%m-%d %H:%M'))
    filter_to = forms.DateTimeField(
        label=_('To date'),
        widget=forms.DateTimeInput(
            attrs={'class': 'datetime fill-up'}, format='%Y-%m-%d %H:%M'))
示例#11
0
from . import defaults
from django import http
from django.template import RequestContext
from spicy.utils import get_custom_model_class
from django.shortcuts import get_object_or_404


SimplePage = get_custom_model_class(defaults.SIMPLE_PAGE_MODEL)


def render_simplepage(request, page, **kwargs):
    """
    Example of universal rubric rendering
    """
    if isinstance(page, basestring):
        page = SimplePage.objects.get(url=page)
    if page.is_active and not request.user.is_staff:
        page = get_object_or_404(SimplePage, url='/errors/404/')
    context = {'page_slug': page.title, 'page': page}
    context.update(**kwargs)
    content_type = 'text/plain' if page.url.endswith('.txt') else 'text/html'
    request.session['SIMPLEPAGE_ID'] = page.pk

    try:
        rendered_page = page.get_template().render(
            RequestContext(request, context))
    except:
        rendered_page = ''

    return http.HttpResponse(rendered_page, content_type=content_type)
示例#12
0
from django.contrib.sites.models import Site
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.db.models import Q
from django import http
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from spicy.core.admin import conf, defaults as admin_defaults
from spicy.core.profile.decorators import is_staff
from spicy.core.service import api
from spicy.core.siteskin.decorators import render_to, ajax_request
from spicy.utils import add_perm, change_perm, delete_perm
from spicy.utils import get_custom_model_class, NavigationFilter, load_module
from . import defaults, forms, models

DocumentModel = get_custom_model_class(defaults.CUSTOM_DOCUMENT_MODEL)


class AdminApp(conf.AdminAppBase):
    name = 'document'
    label = _('Document')
    order_number = 0

    menu_items = (
        conf.AdminLink('document:admin:create',
                       _('Create article'),
                       icon_class='icon-plus-sign-alt',
                       perms=add_perm(defaults.CUSTOM_DOCUMENT_MODEL)),
        conf.AdminLink('document:admin:index',
                       _('All documents'),
                       icon_class='icon-list-alt',
示例#13
0
from django import http
from django.conf import settings
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
from spicy.core.admin import conf, defaults as admin_defaults
from spicy.core.profile.decorators import is_staff
from spicy.core.siteskin.decorators import render_to, ajax_request
from spicy.utils import NavigationFilter, load_module, get_custom_model_class
from . import models, defaults, forms

Feedback = get_custom_model_class(defaults.CUSTOM_FEEDBACK_MODEL)


class AdminApp(conf.AdminAppBase):
    name = 'feedback'
    label = _('Feedbacks')
    order_number = 4

    menu_items = (
        conf.AdminLink('feedback:admin:create', _('Create pattern')),
        conf.AdminLink('feedback:admin:patterns', _('All patterns')),
        conf.AdminLink('feedback:admin:index', _('All feedbacks')),
    )

    perms = conf.Perms(view=[], write=[], manage=[])

    @render_to('menu.html', use_admin=True)
    def menu(self, request, *args, **kwargs):
        return dict(app=self, *args, **kwargs)
示例#14
0
def get_settings_from_db(model_name, field):
    return get_custom_model_class(model_name).objects.get(site__id=SITE_ID)
示例#15
0
from django.db.models import Q
from django import http
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext as _
from spicy.core.admin import conf, defaults as admin_defaults
from spicy.core.service import api
from spicy.core.siteskin.decorators import render_to, ajax_request
from spicy.core.siteskin.decorators import APIResponse, APIResponseFail
from spicy import utils
from spicy.utils.permissions import perm, change_perm, add_perm, delete_perm
from . import defaults, forms
from .decorators import is_staff
from .models import BlacklistedIP

Profile = utils.get_custom_model_class(defaults.CUSTOM_USER_MODEL)

admin.site.register(Profile)


class AdminApp(conf.AdminAppBase):
    name = 'profile'
    label = _('Profile')
    order_number = 10

    menu_items = (
        conf.AdminLink('profile:admin:create',
                       _('Create profile'),
                       perms=add_perm(defaults.CUSTOM_USER_MODEL)),
        conf.AdminLink('profile:admin:index',
                       _('All profiles'),