# coding : utf -8 from quokka import admin from flask.ext.superadmin import model from quokka.core.admin.models import Roled from .models import Role, User class UserAdmin(Roled, model.ModelAdmin): roles_accepted = ('admin',) list_display = ('name', 'email', 'active', 'last_login_at', 'login_count') class RoleAdmin(Roled, model.ModelAdmin): roles_accepted = ('admin',) list_display = ('name', 'description') admin.register(Role, RoleAdmin, category='accounts') admin.register(User, UserAdmin, category='accounts')
# 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"))
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"))
'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"))
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"))
'available_at': ModelAdmin.formatters.get('datetime'), 'values': ModelAdmin.formatters.get('ul'), 'status': ModelAdmin.formatters.get('status'), } column_formatters_args = { 'ul': { 'values': { 'placeholder': u"{item.campaign.title} - {item.value}", 'style': "min-width:200px;max-width:300px;" } }, 'status': { 'status': { 'labels': { 'confirmed': 'success', 'checked_out': 'warning', 'cancelled': 'important', 'completed': 'success' }, 'style': 'min-height:18px;' } } } admin.register(Campaign, CampaignAdmin, category=_("Fundraising"), name=_l("Campaign")) admin.register(Donation, DonationAdmin, category=_("Fundraising"), name=_l("Donation"))
super(Content, self).save(*args, **kwargs) 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 ###############################################################
@property def content_type(self): return self.__class__.__name__ def save(self, *args, **kwargs): self.validate_slug() self.long_slug = "/".join( [self.channel.long_slug, self.slug] ) self.mpath = "".join([self.channel.mpath, self.slug, ',']) super(Content, self).save(*args, **kwargs) class ChannelAdmin(ModelAdmin): roles_accepted = ('admin', 'editor') column_list = ('title', 'long_slug', 'is_homepage') column_filters = ['published', 'is_homepage', 'include_in_rss', 'show_in_menu', 'indexable'] column_searchable_list = ('title', 'description') form_columns = ['title', 'slug', 'description', 'parent', 'is_homepage', 'include_in_rss', 'indexable', 'show_in_menu', 'order', 'published', 'canonical_url'] admin.register(Channel, ChannelAdmin, category="Content")
'created_at', 'sender_email', 'message', 'document', 'status', ] form_args = { 'title': {'label': u'主题'}, 'created_at': {'label': u'提交时间'}, 'sender_email': {'label': u'发件人'}, 'message': {'label': u'简介'}, 'document':{'label':u'附件'}, 'status': {'label': u'状态'}, } admin.register(BrotherInfo, BrotherInfoAdmin, category=_l("Content"), name=_l("BrotherInfo")) admin.register(BrotherVideos, BrotherVideosAdmin, category=_l("Content"), name=_l("BrotherVideos")) admin.register(BrotherArticles, BrotherArticlesAdmin, category=_l("Content"), name=_l("BrotherArticles")) admin.register(Topic, TopicAdmin, category=_l("Content"), name=_l("Topic")) admin.register(News, NewsAdmin, category=_l("Content"), name=_l("News")) admin.register(About, AboutAdmin, category=_l("Content"), name=_l("About")) admin.register(Banner, BannerAdmin, category=_l("Content"), name=_l("Banner")) admin.register(BrotherAsk, BrotherAskAdmin, category=_l("Content"), name=_l("BrotherAsk")) admin.register(JoinMessage, JoinMessageAdmin, category=_l("Content"), name=_l("JoinMessage"))
'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"))
from quokka.core.admin.models import ModelAdmin from .models import PageView from quokka import admin class PageViewAdmin(ModelAdmin): can_edit = False can_delete = True can_add = False list_columns = ('time', 'ip.address', 'path') admin.register(PageView, PageViewAdmin, name='page views', category='analytics')
# 'body': { # 'widget': BigTextArea() # } # } # form_extra_fields = {} # action_disallowed_list # page_size = 20 form_ajax_refs = { 'main_image': {"fields": ('title',)} } admin.register(Catalog, CatalogAdmin, category="Collection") class ProductAdmin(ModelAdmin): roles_accepted = ('admin', 'editor') can_create = True can_edit = True can_delete = True # list_template = 'admin/model/list.html' edit_template = 'admin/custom/edit.html' create_template = 'admin/custom/create.html' column_list = ('title', 'code', 'sku', 'slug', 'channel', 'published', 'view_on_site') def view_on_site(self, request, obj, fieldname, *args, **kwargs):
redis = load_redis() pk = request.args.get('id') if pk in redis.keys("*"): image = pickle.loads(redis.get(pk)) if image is not None: response = Response(image, content_type="image/jpeg", headers={'Content-Length': len(image)}) return response else: response = super(PostImageAdmin, self).api_file_view() image = response.data try: redis.set(pk, pickle.dumps(image), ex=5000) except ResponseError: pass return response def is_accessible(self): return True def _handle_view(self, *args, **kwargs): pass admin.register(PostImage, PostImageAdmin, category="Content", name="images") admin.register(Post, PostAdmin, category=_l("Content"), name=_l("Post")) admin.register(CloudinaryImage, CloudinaryAdmin, category="Content", name="new")
# -*- coding: utf-8 -*- # -*- date: 2016-02-28 11:50 -*- from __future__ import (absolute_import, division, print_function, unicode_literals) from flask.ext.admin.contrib.mongoengine import ModelView from quokka import admin from quokka.core.admin.utils import _l from quokka.modules.accounts.models import Role class RoleAdmin(ModelView): pass admin.register(Role, RoleAdmin, category=_l('Accounts'), name=_l('Roles'))
} post, _ = Post.objects.get_or_create(**post) AggregatedTopic( original_url=entry['feedburner_origlink'].encode( 'ascii', 'ignore'), blog=blog, post=post).save() class AggregatedTopicAdmin(ModelAdmin): roles_accepted = ('admin', 'editor') column_filters = ('date_added', 'original_url', 'blog', 'post') column_searchable_list = ['original_url'] column_list = ('date_added', 'blog', 'original_url', 'post') form_columns = ('date_added', 'blog', 'original_url', 'post') def on_model_delete(self, topic): topic.post.delete() # Register RSSaggregator models to quokka admin page admin.register(ExternalBlogs, ExternalBlogsAdmin, category=_("RSSaggregator"), name=_l("External Blogs")) admin.register(AggregatedTopic, AggregatedTopicAdmin, category=_("RSSaggregator"), name=_l("Aggregated Topics"))
# coding : utf -8 from quokka import admin 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") class RoleAdmin(ModelAdmin): roles_accepted = ("admin",) column_list = ("name", "description") admin.register(User, UserAdmin, category="Accounts") admin.register(Role, RoleAdmin, category="Accounts")
# '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"))
super(Content, self).save(*args, **kwargs) ############################################################### # Admin views ############################################################### class ConfigAdmin(ModelAdmin): roles_accepted = ('admin', 'developer') column_list = ("group", "description", "published", "created_at", "updated_at") column_filters = ("group", "description") form_columns = ("group", "description", "published", "values") admin.register(Config, ConfigAdmin, category="Settings") class ChannelAdmin(ModelAdmin): roles_accepted = ('admin', 'editor') column_list = ('title', 'long_slug', 'is_homepage', 'published') column_filters = ['published', 'is_homepage', 'include_in_rss', 'show_in_menu', 'indexable'] column_searchable_list = ('title', 'description') form_columns = ['title', 'slug', 'description', 'parent', 'is_homepage', 'include_in_rss', 'indexable', 'show_in_menu', 'order', 'published', 'canonical_url', 'values'] form_subdocuments = {}
# 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")))
# 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"))
# 'body': { # 'widget': BigTextArea() # } # } # form_extra_fields = {} # action_disallowed_list # page_size = 20 form_ajax_refs = { 'main_image': {"fields": ('title',)} } admin.register(Band, BandAdmin, category="Music") class ArtistAdmin(ModelAdmin): """ All attributes added here for example more info in admin source github.com/mrjoes/flask-admin/blob/master/flask_admin/model/base.py or Flask-admin documentation """ roles_accepted = ('admin', 'editor') can_create = True can_edit = True can_delete = True
super(Content, self).save(*args, **kwargs) ############################################################### # Admin views ############################################################### class ConfigAdmin(ModelAdmin): roles_accepted = ('admin', 'developer') column_list = ("group", "description", "published", "created_at", "updated_at") column_filters = ("group", "description") form_columns = ("group", "description", "published", "values") admin.register(Config, ConfigAdmin, category="Settings") class ChannelAdmin(ModelAdmin): roles_accepted = ('admin', 'editor') column_list = ('title', 'long_slug', 'is_homepage', 'published') column_filters = ['published', 'is_homepage', 'include_in_rss', 'show_in_menu', 'indexable'] column_searchable_list = ('title', 'description') form_columns = ['title', 'slug', 'description', 'parent', 'is_homepage', 'include_in_rss', 'indexable', 'show_in_menu', 'order', 'published', 'canonical_url', 'values'] admin.register(Channel, ChannelAdmin, category="Content")
) ) 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"))
# coding : utf -8 from quokka import admin 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") admin.register(Role, RoleAdmin, category="Accounts")
# but the objects can also be relates to other channels channels = db.ListField(db.ReferenceField('Channel')) ############################################################### # Base Content for every new content to extend. inheritance=True ############################################################### class Content(db.DynamicDocument, Publishable, Slugged, Commentable, Channeling): title = db.StringField(max_length=255, required=True) summary = db.StringField(required=False) def get_absolute_url(self): return url_for(self.URL_NAMESPACE, slug=self.slug) def __unicode__(self): return self.title @property def post_type(self): return self.__class__.__name__ meta = { 'allow_inheritance': True, 'indexes': ['-created_at', 'slug'], 'ordering': ['-created_at'] } admin.register(Channel)
'cols': 20, 'class': 'html_editor', 'style': "margin: 0px; width: 725px; height: 360px;" }, 'summary': { 'style': 'width: 400px; height: 100px;' }, 'title': { 'style': 'width: 400px' }, 'slug': { 'style': 'width: 400px' }, } # form_args = { # 'body': { # 'widget': BigTextArea() # } # } # form_extra_fields = {} # action_disallowed_list # page_size = 20 form_ajax_refs = {'main_image': {"fields": ('title', )}} admin.register(Post, PostAdmin, category="Content")
# form_overrides = None form_widget_args = { 'body': { 'rows': 20, 'cols': 20, 'class': 'html_editor', 'style': "margin: 0px; width: 725px; height: 360px;" }, 'summary': { 'style': 'width: 400px; height: 100px;' }, 'title': {'style': 'width: 400px'}, 'slug': {'style': 'width: 400px'}, } # form_args = { # 'body': { # 'widget': BigTextArea() # } # } # form_extra_fields = {} # action_disallowed_list # page_size = 20 admin.register(Post, PostAdmin, category="Content")
form_columns = ('name', 'email', 'roles', 'active', 'newpassword', 'confirmed_at', 'last_login_at', 'current_login_at', 'last_login_ip', 'current_login_ip', 'login_count', 'tagline', 'gravatar_email', 'bio', 'links', 'values') 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', 'values') class ConnectionAdmin(ModelAdmin): roles_accepted = ('admin',) admin.register(User, UserAdmin, category=_l("Accounts"), name=_l("User")) admin.register(Role, RoleAdmin, category=_l("Accounts"), name=_l("Roles")) admin.register(Connection, ConnectionAdmin, category=_l("Accounts"), name=_l("Connection"))
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"))
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', 'values') class ConnectionAdmin(ModelAdmin): roles_accepted = ('admin',) admin.register(User, UserAdmin, category=_l("Accounts"), name=_l("User")) admin.register(Role, RoleAdmin, category=_l("Accounts"), name=_l("Roles")) admin.register(Connection, ConnectionAdmin, category=_l("Accounts"), name=_l("Connection")) admin.register(DBImage, DBImageAdmin, name="DB Images") #admin.register(UserProfile, UserProfileAdmin, category=_l("Accounts"),name=_l("User Profiles")) #admin.register(TestImage, TestAdmin, category=_l('Test'),name=_l('Test')) #admin.register(ContactInfo, ContactInfoAdmin, category=_l('Accounts'), name=_l('Contact Info'))