Exemple #1
0
from quokka.core.admin.models import ModelAdmin
from .models import Role, User, Connection


class UserAdmin(ModelAdmin):
    roles_accepted = ('admin', )
    column_searchable_list = ('name', 'email')
    column_list = ('name', 'email', 'active', 'last_login_at', 'login_count')
    form_columns = ('name', 'email', 'roles', 'active', 'newpassword',
                    'confirmed_at', 'last_login_at', 'current_login_at',
                    'last_login_ip', 'current_login_ip', 'login_count',
                    'tagline', 'bio', 'links')

    form_extra_fields = {"newpassword": TextField(widget=PasswordInput())}

    def on_model_change(self, form, model, is_created):
        if model.newpassword:
            setpwd = model.newpassword
            del model.newpassword
            model.set_password(setpwd, save=True)


class RoleAdmin(ModelAdmin):
    roles_accepted = ('admin', )
    column_list = ('name', 'description')


admin.register(User, UserAdmin, category=_("Accounts"), name=_l("User"))
admin.register(Role, RoleAdmin, category=_("Accounts"), name=_l("Roles"))
admin.register(Connection, category=_("Accounts"), name=_l("Connection"))
Exemple #2
0
        if not is_created and model.reference:
            model.reference.published = model.published
            if model.tax:
                model.set_reference_tax(float(model.tax))
            model.reference.save()


class ProcessorAdmin(ModelAdmin):
    roles_accepted = ("admin", "developer")
    column_list = ("identifier", "title", "module", "published")
    form_args = {"description": {"widget": TextEditor()}, "identifier": {"widget": PrepopulatedText(master="title")}}
    form_columns = (
        "title",
        "identifier",
        "description",
        "module",
        "requires",
        "image",
        "link",
        "config",
        "pipeline",
        "published",
    )
    form_ajax_refs = {"image": {"fields": ["title", "long_slug", "summary"]}}

    form_widget_args = {"config": {"cols": 40, "rows": 10, "style": "width:500px;"}}


admin.register(Cart, CartAdmin, category=_("Cart"), name=_l("Cart"))
admin.register(Processor, ProcessorAdmin, category=_("Cart"), name=_l("Processor"))
Exemple #3
0
class ProcessorAdmin(ModelAdmin):
    roles_accepted = ('admin', 'developer')
    column_list = ('identifier', 'title', 'module', 'published')
    form_args = {
        "description": {
            "widget": TextEditor()
        },
        "identifier": {
            "widget": PrepopulatedText(master='title')
        }
    }
    form_columns = ('title', 'identifier', 'description', 'module', 'requires',
                    'image', 'link', 'config', 'pipeline', 'published')
    form_ajax_refs = {'image': {'fields': ['title', 'long_slug', 'summary']}}

    form_widget_args = {
        'config': {
            'cols': 40,
            'rows': 10,
            'style': 'width:500px;'
        }
    }


admin.register(Cart, CartAdmin, category=_("Cart"), name=_l("Cart"))
admin.register(Processor,
               ProcessorAdmin,
               category=_("Cart"),
               name=_l("Processor"))
Exemple #4
0
# coding : utf -8


from quokka import admin
from quokka.core.admin import _, _l
from quokka.core.admin.models import ModelAdmin
from quokka.core.widgets import TextEditor
from .models import Comment


class CommentAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor', 'moderator')
    column_list = ('path', 'author_name', 'author_email',
                   'created_at', 'published')
    form_columns = ['path', 'author_email', 'author_name',
                    'content_format', 'body', 'replies',
                    'created_at', 'created_by', 'published']
    form_args = {
        'body': {'widget': TextEditor()}
    }


admin.register(Comment, CommentAdmin, category=_('Content'),
               name=_l("Comments"))
Exemple #5
0
# coding : utf -8

from quokka import admin
from quokka.core.admin.models import BaseContentAdmin
from quokka.core.widgets import TextEditor, PrepopulatedText
from quokka.core.admin import _, _l
from .models import Post


class PostAdmin(BaseContentAdmin):

    column_searchable_list = ('title', 'body', 'summary')

    form_columns = ['title', 'slug', 'channel', 'related_channels', 'summary',
                    'content_format', 'body',
                    'comments_enabled', 'published', 'contents',
                    'show_on_channel', 'available_at', 'available_until',
                    'tags', 'values', 'template_type']

    form_args = {
        'body': {'widget': TextEditor()},
        'slug': {'widget': PrepopulatedText(master='title')}
    }


admin.register(Post, PostAdmin, category=_("Content"), name=_l("Post"))
Exemple #6
0
            'cols': 10,
            'class': 'text_editor',
            'style': "margin: 0px; width: 400px; height: 100px;"
        },
        'choice_C': {
            'rows': 5,
            'cols': 10,
            'class': 'text_editor',
            'style': "margin: 0px; width: 400px; height: 100px;"
        },
        'choice_D': {
            'rows': 5,
            'cols': 10,
            'class': 'text_editor',
            'style': "margin: 0px; width: 400px; height: 100px;"
        },
        'choice_E': {
            'rows': 5,
            'cols': 10,
            'class': 'text_editor',
            'style': "margin: 0px; width: 400px; height: 100px;"
        },
        'summary': {
            'style': 'width: 400px; height: 100px;'
        },
        'title': {'style': 'width: 400px'},
        'slug': {'style': 'width: 400px'},
    }

admin.register(Question, QuestionAdmin, category=_("Content"), name=_l("Question"))
Exemple #7
0

class Link(Content):
    link = db.StringField(required=True)


###############################################################
# General Content admin
###############################################################


class ContentAdmin(ModelAdmin):
    roles_accepted = ('admin', 'developer')

admin.register(Content, ContentAdmin,
               category=_('Settings'), name=_l("Content"))


class LinkAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor', 'writer', 'moderator')
    column_list = ('title', 'channel', 'slug', 'published')
    form_columns = ('title', 'slug', 'channel', 'link', 'contents',
                    'values', 'available_at', 'available_until', 'published')

admin.register(Link, LinkAdmin, category=_("Content"), name=_l("Link"))


###############################################################
# Admin views
###############################################################
Exemple #8
0

class Link(Content):
    link = db.StringField(required=True)


###############################################################
# General Content admin
###############################################################


class ContentAdmin(ModelAdmin):
    roles_accepted = ('admin', 'developer')

admin.register(Content, ContentAdmin,
               category=_('Settings'), name=_l("Content"))


class LinkAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor', 'writer', 'moderator')
    column_list = ('title', 'channel', 'slug', 'published')
    form_columns = ('title', 'slug', 'channel', 'link', 'contents',
                    'values', 'available_at', 'available_until', 'published')

admin.register(Link, LinkAdmin, category=_("Content"), name=_l("Link"))


###############################################################
# Admin views
###############################################################
Exemple #9
0
            )
        )

    column_formatters = {
        'thumb': _list_thumbnail
    }

    form_extra_fields = {
        'path': ImageUploadField(
            'Image',
            base_path=lazy_media_path(),
            thumbnail_size=(100, 100, True),
            endpoint="media",
            namegen=dated_path,
            permission=0o777,
            allowed_extensions="MEDIA_IMAGE_ALLOWED_EXTENSIONS",
        )
    }


class MediaGalleryAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor')


admin.register(File, FileAdmin, category=_('Media'), name=_l("File"))
admin.register(Video, VideoAdmin, category=_('Media'), name=_l("Video"))
admin.register(Audio, AudioAdmin, category=_('Media'), name=_l("Audio"))
admin.register(Image, ImageAdmin, category=_('Media'), name=_l("Image"))
admin.register(MediaGallery, MediaGalleryAdmin,
               category=_('Content'), name=_l("Media Gallery"))
Exemple #10
0
# coding : utf -8

from quokka import admin
from quokka.core.admin import _, _l
from quokka.core.admin.models import ModelAdmin
from quokka.core.widgets import TextEditor
from .models import Comment


class CommentAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor')
    column_list = ('path', 'author_name', 'author_email', 'created_at',
                   'published')
    form_columns = [
        'path', 'author_email', 'author_name', 'content_format', 'body',
        'replies', 'created_at', 'created_by', 'published'
    ]
    form_args = {'body': {'widget': TextEditor()}}


admin.register(Comment,
               CommentAdmin,
               category=_('Content'),
               name=_l("Comments"))
Exemple #11
0
# coding : utf -8
from quokka import admin
from quokka.core.admin import _, _l
from quokka.core.admin.models import ModelAdmin
from .models import Role, User


class UserAdmin(ModelAdmin):
    roles_accepted = ('admin',)
    column_list = ('name', 'email', 'active',
                   'last_login_at', 'login_count')
    form_columns = ('name', 'email', 'roles', 'active', 'confirmed_at',
                    'last_login_at', 'current_login_at', 'last_login_ip',
                    'current_login_ip', 'login_count')


class RoleAdmin(ModelAdmin):
    roles_accepted = ('admin',)
    column_list = ('name', 'description')


admin.register(User, UserAdmin, category=_("Accounts"), name=_l("User"))
admin.register(Role, RoleAdmin, category=_("Accounts", name=_l("Roles")))
Exemple #12
0
    #     'body': {
    #         'widget': BigTextArea()
    #     }
    # }

    form_subdocuments = {
        'contents': {
            'form_subdocuments': {
                None: {
                    'form_columns': ('content', 'caption', 'purpose', 'order'),
                    'form_ajax_refs': {
                        'content': {
                            'fields': ['title', 'long_slug', 'summary']
                        }
                    }
                }
            }
        },
    }
    # form_extra_fields = {}

    # action_disallowed_list

    # page_size = 20
    # form_ajax_refs = {
    #     'main_image': {"fields": ('title',)}
    # }


admin.register(Post, PostAdmin, category=_("Content"), name=_l("Post"))
Exemple #13
0
        'status', 'confirmed_date',
        'unity_value',
        'published'
    ]

    form_columns = [
        'course', 'classroom',
        'student', 'subscriber',
        'status', 'confirmed_date',
        'unity_value',
        'published', 'available_at', 'available_until',
        'created_at',
        'cart'
    ]


class SubscriberAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor')

admin.register(Course, CourseAdmin, category=_("Classes"), name=_l("Course"))

admin.register(Subscriber,
               SubscriberAdmin,
               category=_("Classes"),
               name=_l("Subscriber"))

admin.register(CourseSubscription,
               CourseSubscriptionAdmin,
               category=_("Classes"),
               name=_l("Subscription"))