'app_label': 'acm_members' } } class DashboardOption(NavOption): name = u'Dashboard' view = 'acm_members.views.dashboard' class AcmMembersNav(Nav): """ This is a primary Navigation link, Most apps should only define one of these If the application truly wants to have Navigation links for all of their landing pages They can use the NavOption and have the main Nav with their Home state """ name = u'ACM Members' icon = 'cog' nav_group = 'apis' options = [DashboardOption, ManageOption, APIOption] conditional = { 'function': user_can_see, 'args': [], 'kwargs': { 'app_label': 'acm_members' } } nav_groups.register(AcmMembersNav)
class ProfileOption(NavOption): name = '个人信息维护' view = 'sysmgr-profile' class LoginMgrOption(NavOption): name = '修改密码' view = 'sysmgr-profile' class SysMgrNav(Nav): name = '系统信息维护' view = 'sysmgr' nav_group = 'main' options = [MetaMgrOption, BatchImportOption, BatchUploadOption, FTPOption, ProfileOption] nav_groups.register(SysMgrNav) class BatchImportShortcut(Nav): name = '批量数据导入' view = 'sysmgr-import' nav_group = 'shortcut' template = 'dashboard/shortcut.html' icon = 'images/icons/paper_content_pencil_48.png' class LicenseFileMgrShortcut(Nav): name = '证书文件管理' view = 'patent-file' nav_group = 'shortcut' template = 'dashboard/shortcut.html' icon = 'images/icons/image_add_48.png'
url = '/louisville_crime/api/' class ManageOption(NavOption): """ This is an Option of an Option, this can go on for the max recursion depth of python (Further then you want to try and go) """ name = u'Manage' icon = '' view = '' conditional = {'function': user_can_manage, 'args': [], 'kwargs': {'app_label':'louisville_crime'}} class DashboardOption(NavOption): name = u'Dashboard' view = 'louisville_crime.views.dashboard' class LouisvilleCrimeNav(Nav): """ This is a primary Navigation link, Most apps should only define one of these If the application truly wants to have Navigation links for all of their landing pages They can use the NavOption and have the main Nav with their Home state """ name = u'Louisville Crime' #view = 'louisville_crime.views.dashboard' icon = 'cog' nav_group = 'apis' options = [DashboardOption, ManageOption, APIOption] conditional = {'function': user_can_see, 'args': [], 'kwargs': {'app_label':'louisville_crime'}} nav_groups.register(LouisvilleCrimeNav)
# coding=utf-8 from django_nav import nav_groups, Nav, NavOption from django_nav.conditionals import * class DashboardNav(Nav): name = 'Dashboard' view = 'dashboard' nav_group = 'main' conditional = { 'function': user_has_perm, 'args': [], 'kwargs': { 'perm': 'rankmgr.can_operate_package' }, } nav_groups.register(DashboardNav)
create_template = 'reversion/version_create.html' update_template = 'reversion/version_update.html' popup_template = 'reversion/version_popup.html' detail_template = 'reversion/version_detail.html' def get_request_queryset(self, request): qs = super(VersionModelAdmin, self).get_request_queryset(request) if not request.user.is_superuser: return Version.objects.sieve(user=request.user) return qs def get_import_urls(self): return patterns('',) def get_export_urls(self): return patterns('',) class ReversionAppAdmin(BetterAppAdmin): app_name = 'reversion' model_admins = { 'Revision': RevisionModelAdmin(), 'Version': VersionModelAdmin(), } reversion_app_admin = ReversionAppAdmin() nav_groups.register(reversion_app_admin.get_nav()) urlpatterns += reversion_app_admin.get_urls()
name = u'API' url = '/acm_members/api/' class ManageOption(NavOption): """ This is an Option of an Option, this can go on for the max recursion depth of python (Further then you want to try and go) """ name = u'Manage' icon = '' view = '' conditional = {'function': user_can_manage, 'args': [], 'kwargs': {'app_label':'acm_members'}} class DashboardOption(NavOption): name = u'Dashboard' view = 'acm_members.views.dashboard' class AcmMembersNav(Nav): """ This is a primary Navigation link, Most apps should only define one of these If the application truly wants to have Navigation links for all of their landing pages They can use the NavOption and have the main Nav with their Home state """ name = u'ACM Members' icon = 'cog' nav_group = 'apis' options = [DashboardOption, ManageOption, APIOption] conditional = {'function': user_can_see, 'args': [], 'kwargs': {'app_label':'acm_members'}} nav_groups.register(AcmMembersNav)
class PATFileUploadOption(NavOption): name = '专利证书上传' view = 'patent-file' class PATMgrNav(Nav): name = '专利登记管理' view = 'patent' nav_group = 'main' options = [PATApplyOption, PATListOption, PATImportOption, PATFileUploadOption, PATExtFieldMgrOption, PATRetvMgrOption] conditional = { 'function': user_has_perm, 'args': [], 'kwargs': { 'perm': 'rankmgr.can_operate_package' }, } nav_groups.register(PATMgrNav) class PATApplyShortcut(Nav): name = '专利申请登记' view = 'patent-add' nav_group = 'shortcut' template = 'dashboard/shortcut.html' icon = 'images/icons/pencil_48.png' class PATImportShortcut(Nav): name = '专利数据导入' view = 'patent-import' nav_group = 'shortcut' template = 'dashboard/shortcut.html' icon = 'images/icons/paper_content_pencil_48.png'
conditional = { 'function': user_has_perm, 'args': [], 'kwargs': {'perm': 'rankmgr.can_operate_package'}, } class RankMgrNav(Nav): name = '知识产权等级评定' view = 'rank' nav_group = 'main' options = [PATPackageOption, PATRatingOption, PATSubmittedRatingOption, #PATRejectedRatingOption, SummaryOption, ExpertMgrOption] nav_groups.register(RankMgrNav) #class PATRatingNav(Nav): # name = '待评价专利列表' # view = 'patent-rating-list' # nav_group = 'main' regex = re.compile(r'^/dashboard/rank/rating/(?:list|(\d+/pending))/$') # conditional = { # 'function': user_has_perm, # 'args': [], # 'kwargs': {'perm': 'rankmgr.can_operate_rating'}, # } #class PATSubmittedRatingNav(Nav): # name = '已评价专利列表' # view = 'submit-patent-rating-list' # nav_group = 'main' # regex = re.compile(r'^/dashboard/rank/rating/(?:list/submit|(\d+/submit))/')
They can use the NavOption and have the main Nav with their Home state """ name = u'ACM Archiver' view = 'archiver.views.dashboard' icon = 'cog' nav_group = 'main' class LoginOption(NavOption): name = u'Login' url = '/accounts/login/' template = 'django_nav/topoption.html' conditional = {'function': user_is_not_authenticated, 'args': [], 'kwargs': {}} class LogoutOption(NavOption): name = u'Logout' url = '/accounts/logout/' template = 'django_nav/topoption.html' conditional = {'function': user_is_authenticated, 'args': [], 'kwargs': {}} class UserTopNav(Nav): name = u'Welcome {{ user }} ' icon = 'user' nav_group = 'top' template = 'django_nav/topnav.html' options = [LoginOption, LogoutOption] nav_groups.register(UserTopNav) nav_groups.register(ArchiverNav)
class LoginOption(NavOption): name = u'Login' url = '/accounts/login/' template = 'django_nav/topoption.html' conditional = { 'function': user_is_not_authenticated, 'args': [], 'kwargs': {} } class LogoutOption(NavOption): name = u'Logout' url = '/accounts/logout/' template = 'django_nav/topoption.html' conditional = {'function': user_is_authenticated, 'args': [], 'kwargs': {}} class UserTopNav(Nav): name = u'Welcome {{ user }} ' icon = 'user' nav_group = 'top' template = 'django_nav/topnav.html' options = [LoginOption, LogoutOption] nav_groups.register(UserTopNav) nav_groups.register(ArchiverNav)
# admin.autodiscover() urlpatterns = patterns('') + \ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) from better_admin_test_app.models import KAM from better_admin.core import BetterModelAdmin from better_admin_test_app.views import KAMBetterListView class BetterKAMModelAdmin(BetterModelAdmin): queryset = KAM.objects.all() list_view = KAMBetterListView def get_request_queryset(self, request): return KAM.objects.filter(user=request.user) class BetterAdminTestAppAdmin(BetterAppAdmin): app_name = 'better_admin_test_app' model_admins = {'KAM': BetterKAMModelAdmin()} """ class BetterAdminTestAppAdmin(BetterAppAdmin): app_name = 'better_admin_test_app' """ better_admin_test_app_admin = BetterAdminTestAppAdmin() urlpatterns += better_admin_test_app_admin.get_urls() nav_groups.register(better_admin_test_app_admin.get_nav()) enable_auth(urlpatterns, nav_groups)
class SCRRetrvMgrOption(NavOption): name = '检索方案管理' view = 'scr-retrvscheme' class SCRMgrNav(Nav): name = '软件著作权登记管理' view = 'scrmgr.views.scrmgr' nav_group = 'main' options = [SCRApplyOption, SCRListOption, SCRImportOption, SCRFileUploadOption, SCRExtFieldMgrOption, SCRRetrvMgrOption] conditional = { 'function': user_has_perm, 'args': [], 'kwargs': { 'perm': 'rankmgr.can_operate_package' }, } nav_groups.register(SCRMgrNav) class SCRApplyShortcut(Nav): name = '软件著作权登记' view = 'scr-add' nav_group = 'shortcut' template = 'dashboard/shortcut.html' icon = 'images/icons/pencil_48.png' class SCRImportShortcut(Nav): name = '软件著作权数据导入' view = 'scrmgr.views.scrmgr' nav_group = 'shortcut' template = 'dashboard/shortcut.html' icon = 'images/icons/paper_content_pencil_48.png'