当前位置: 首页>>代码示例>>Python>>正文


Python Page.breadcrumbs方法代码示例

本文整理汇总了Python中packages.bin.bin.Page.breadcrumbs方法的典型用法代码示例。如果您正苦于以下问题:Python Page.breadcrumbs方法的具体用法?Python Page.breadcrumbs怎么用?Python Page.breadcrumbs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在packages.bin.bin.Page的用法示例。


在下文中一共展示了Page.breadcrumbs方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: auth_error

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def auth_error(request, error=None):

    s = Auth().is_auth(request)
    if not s:
        return Auth.routeLogin

    base_template = 'system/'
    second_base = 'error/'

    page = Page(request)
    page.title = _('Page Error')
    page.icon = 'glyphicons glyphicons-ban'
    page.breadcrumbs = [_('System'), _('Page Error'), _(error)]
    page.body_class = 'error-page sb-l-o sb-r-c'

    try:
        page.route_to = request.session['error-route']
    except KeyError:
        page.route_to = "/"

    return render_to_response(
        base_template+second_base+'%s.html' % error,
        {'s': s, 'page': page},
        context_instance=RequestContext(request)
    )
开发者ID:ushiang,项目名称:onc,代码行数:27,代码来源:views.py

示例2: report_basket

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def report_basket(request, module=None): 

    s = Auth().is_auth(request)
    if not s: 
        return Auth.routeLogin

    me = Auth.whoami(request, "users")

    from packages.bin.extras.time_ago import ago_time

    base_template = 'system/'

    page = Page(request)
    page.title = _('Report Basket - ') + Auth.whoami(request).get_fullname()
    page.icon = 'fa fa-stats'
    page.breadcrumbs = [_('Report Basket View')]
    page.errors = []
    page.user = me.username

    if module: 
        module = Module.objects.get(alias=module)
        obj = me.users_report.filter(module=module)
    else: 
        obj = me.users_report.all()

    count = obj.count()
    if count > 25: 
        to_delete = obj.order_by('-modified')[:20]
        for x in to_delete: 
            x.delete()

    obj = obj.order_by('-modified')

    table = Table()
    table.cols = [_('Report Name'), _('Download Report'), _('Generated By App'), _('Generated'),
                  _('Delete Report')]
    table.rows = []
    for val in obj: 
        download_link = "<a href='%(link)s' class='btn btn-sm btn-default' target='_blank'>" \
                        "<span class='fa fa-cloud-download'></span> %(name)s</a>" % \
                        {
                            'link': get_media_root_url(request) + val.file_url,
                            'name': _("Download"),
                            'filename': val.name
                        }
        # email_link = "<a ui-WitMVC-href href='%(link)s' class='btn btn-sm btn-default'>" \
        #              "<span class='fa fa-mail-forward'></span> %(name)s</a>" % {
        #                  'link': '#system/email/report/%s/' % val.pk,
        #                  'name': _("Forward as Mail")
        #              }
        delete_link = "<a ui-WitMVC-href href='%(link)s' class='btn btn-sm btn-danger' data-action='true' " \
                      "data-method='get'> " \
                      "<span class='fa fa-trash-o'></span> %(name)s</a>" % {
                          'link': '#system/report/delete/%s/' % val.pk if not module else
                          '#system/report/delete/%s/%s/' % (module.alias, val.pk),
                          'name': _("Delete")
                      }

        table.rows.append({
            'id': val.id,
            'fields': [
                {'field': _(val.module.name)},
                {'field': val.name},
                {'field': download_link},
                {'field': ago_time(val.modified)},
                {'field': delete_link}
            ]
        })

    return render_to_response(base_template+'snippets/list.html', {'s': s, 'table': table, 'page': page})
开发者ID:ushiang,项目名称:onc,代码行数:72,代码来源:views.py

示例3: system_license

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def system_license(request, pk=None, method=None):

    # check if root login
    if request.session['auth_username'] != 'root': 
        return HttpResponse(response_success(route='#hr/personnel/'))

    s = request.session

    base_url = '/pp-license/'
    second_base = ''
    base_template = 'system/'

    page = Page(request)
    page.title = 'License Management'
    page.icon = 'fa fa-unlock-alt'
    page.form_name = 'licenseForm'
    page.breadcrumbs = ['License Management', 'Manage']
    errors = []

    page.user = request.session['auth_username']

    # query table list
    obj_list = License.objects.all()

    # search logic
    q = request.GET.get('q')
    if q: 
        search_query = get_query(q, ['company__name', 'company_name', 'sys', 'lid'])
        obj_list = obj_list.filter(search_query)

    # build pagination
    page, obj = paginate(page, obj_list, request, q)

    # login url processing
    if method is None or (method != 'new' and method != 'update'): 
        instance = License()
        form = FormLicense()
        template = base_template + 'snippets/list.html'
    elif pk is not None: 
        instance = License.objects.get(pk=pk)
        form = FormLicense(instance=instance, data=model_to_dict(instance))
        page.form_action = base_url + 'update/'+str(pk)+'/'
        template = base_template + 'snippets/manage.html'
    else: 
        instance = License()
        form = FormLicense(instance=instance)
        page.form_action = base_url + 'new/'
        template = base_template + 'snippets/manage.html'

    obj_settings = [
        {'link': base_url+'update/', 'icon': ActionButton.edit},
        {'link': base_url+'delete/', 'icon': ActionButton.delete},
    ]

    table = Table()
    table.cols = ['Company', 'Company Secret Key', 'License Number', 'Expiry']
    table.rows = []
    for val in obj: 

        try: 
            expiry = val.license_subscription.filter(status=1)[0]
        except IndexError: 
            expiry = None

        expiry = "<a href='#pp-license/subscription/new/{pk}/'>{expiry}</a>".format(expiry=expiry, pk=val.pk)

        table.rows.append({
            'id': val.id,
            'fields': [
                {'field': val.company_name},
                {'field': val.sys},
                {'field': val.lid},
                {'field': expiry}
            ]
        })

    # maintain autocomplete state
    try: 
        instance_var = instance.modules.all()
    except (AttributeError, ValueError): 
        instance_var = []

    # script for autocomplete
    page.script = autocomplete_state(
        instance_var=instance_var,
        queryset=Module.objects.all(),
        url='/bin/json/system/modules/',
        element='id_modules',
        token=20,
    )

    # CREATE & UPDATE
    if request.method == "POST":

        form = FormLicense(request.POST, request.FILES, instance=instance)
        modules = []

        if form.is_valid(): 
            # do method to process
            posts = request.POST
#.........这里部分代码省略.........
开发者ID:ushiang,项目名称:onc,代码行数:103,代码来源:views.py

示例4: subscription

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def subscription(request, pk=None, method=None):

    # check if root login
    if request.session['auth_username'] != 'root': 
        return HttpResponse(response_success(route='#hr/personnel/'))

    s = request.session
    base_url = '/pp-license/'
    second_base = 'subscription/'
    base_template = 'system/'

    page = Page(request)
    page.title = 'License Management'
    page.icon = 'fa fa-unlock-alt'
    page.form_name = 'subscriptionForm'
    page.breadcrumbs = ['License Management', 'Subscription']
    errors = []

    page.user = request.session['auth_username']

    # query table list
    obj = Subscription.objects.filter(license__id=pk)

    # login url processing
    if method is None or (method != 'new' and method != 'update'): 
        instance = Subscription()
        form = FormSubscription()
        template = base_template + 'snippets/list.html'

    else: 
        instance = Subscription()
        instance.license = License.objects.get(pk=pk)
        form = FormSubscription(instance=instance)
        page.form_action = base_url + second_base + 'new/' + str(pk) + '/'
        template = base_template + 'snippets/manage.html'

    obj_settings = [
        {'link': base_url+'update/', 'icon': ActionButton.edit},
        {'link': base_url+'delete/', 'icon': ActionButton.delete},
    ]

    table = Table()
    table.cols = ['License', 'Expiry']
    table.rows = []
    for val in obj: 

        table.rows.append({
            'id': val.id,
            'fields': [
                {'field': val.license},
                {'field': val.expiry}
            ]
        })

    # CREATE & UPDATE
    if request.method == "POST": 

        form = FormSubscription(request.POST, instance=instance)

        if form.is_valid(): 
            # do method to process
            posts = request.POST
            for post in posts: 
                # skip the many to many fields
                if hasattr(instance, post): 
                    setattr(instance, post, form.cleaned_data[post])

        # non field specific errors
        page.non_field_errors = errors

        errors += format_form_error(form)

        # if not errors and not form.errors:
        if not errors: 
            Subscription.objects.filter(license__id=pk).update(status=0)
            instance.save()

            return HttpResponse(response_success(route=base_url+second_base))

        else: 
            return HttpResponse(response_error(response=[errors]))

    # render to browser
    return render_to_response(
        template,
        {'s': s, 'form': form, 'page': page, 'table': table, 'obj': obj, 'settings': obj_settings},
        context_instance=RequestContext(request)
    )
开发者ID:ushiang,项目名称:onc,代码行数:90,代码来源:views.py

示例5: uc_user

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def uc_user(request):

    s = Auth().is_auth(request)
    if not s: 
        return Auth.routeLogin

    second_base = 'uc_user/'

    page = Page(request)
    page.title = 'Users\' Class'
    page.icon = 'fa fa-list-alt'
    page.form_name = 'usersClass'
    page.breadcrumbs = ['Privileges', 'Associated User Class']

    obj = UserClassTies.pp.filter(status__exact=1)

    #url processing
    instance = UserClassTies()
    form = forms.FormUserClassTies(instance=instance)
    page.form_action = base_url + second_base + 'new/'
    template = base_template + 'manage.html'

    #script for form
    page.script = '''
    <script>

    $(document).ready(function(){
        $('#id_user_class').tokenInput('/bin/json/system/privilege/user_class/',
            {theme: 'wit', tokenLimit: 100, hintText: 'Start typing name'});
        $('#id_user').tokenInput('/bin/json/system/user/',
            {theme: 'wit', tokenLimit: 100, hintText: 'Start typing name'});
    });
    </script>'''

    # CREATE & UPDATE
    if request.method == "POST": 

        errors = []

        # check for errors
        if request.POST['user_class'] == "": 
            errors.append("Please select at least one user class")

        if request.POST['user'] == "": 
            errors.append("Please select at least one users")

        # conclude
        if not errors: 

            # iterate through values and save individually
            for x in request.POST['user_class'].split(','):
                c_user_class = UserClass.objects.get(pk=x)
                for y in request.POST['user'].split(','): 
                    c_user = Users.pp.get(pk=y)

                    UserClassTies.pp.filter(user=c_user, user_class__module=c_user_class.module).delete()
                    UserClassTies.pp.create(user_class=c_user_class, user=c_user)

            response = 'Saved successfully'
            return HttpResponse(response_success(route=base_url + 'user_class/', response=response))

        else: 
            return HttpResponse(response_error(response=[errors]))

    #render to browser
    return render_to_response(
        template,
        {'s': s, 'form': form, 'page': page, 'obj': obj},
        context_instance=RequestContext(request)
    )
开发者ID:pukonu,项目名称:estate,代码行数:72,代码来源:privilege.py

示例6: manifest

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def manifest(request, pk=None, method=None): 

    s = Auth().is_auth(request)
    if not s: 
        return Auth.routeLogin

    second_base = 'manifest/'

    page = Page(request)
    page.title = 'Privilege Manifest'
    page.icon = 'fa fa-list-alt'
    page.form_name = 'privilegeManifest'
    page.breadcrumbs = ['Privileges', 'Manifest']
    errors = []

    obj_list = PrivilegeManifest.objects.filter(status__exact=1).order_by('module__name', 'name')

    #search logic
    q = request.GET.get('q')
    if q: 
        search_query = get_query(q, ['name'])
        obj_list = obj_list.filter(search_query)

    #build pagination
    page, obj = paginate(page, obj_list, request, q)

    #login url processing
    if method is None or method == 'index':
        instance = PrivilegeManifest()
        form = forms.FormUserClass()
        template = base_template + 'list.html'
    elif pk is not None: 
        instance = PrivilegeManifest.objects.get(pk=pk)
        form = forms.FormPrivilegeManifest(instance=instance, data=model_to_dict(instance))
        page.form_action = base_url + second_base + 'update/'+str(pk)+'/'
        template = base_template + 'manage.html'
    else: 
        instance = PrivilegeManifest()
        form = forms.FormPrivilegeManifest(instance=instance)
        page.form_action = base_url + second_base + 'new/'
        template = base_template + 'manage.html'

    obj_settings = [
        {'link': base_url+second_base+'update/', 'icon': ActionButton.edit},
        {'link': base_url+'manifest-delete/', 'icon': ActionButton.delete},
    ]

    table = Table()
    table.cols = ['Module', 'Name', 'Associated User Classes']
    table.rows = []
    for val in obj: 
        tmp = val.manifest_privilege.all()
        assoc = ""
        for x in tmp: 
            assoc += "%s<br/>" % x.user_class.name
        table.rows.append({
            'id': val.id,
            'fields': [
                {'field': val.module.name},
                {'field': val.name},
                {'field': assoc}
            ]
        })

    # CREATE & UPDATE
    if request.method == "POST": 

        form = forms.FormPrivilegeManifest(request.POST, instance=instance)
        if form.is_valid(): 
            #do method to process
            posts = request.POST
            for post in posts: 
                if hasattr(instance, post): 
                    setattr(instance, post, form.cleaned_data[post])

        # non field specific errors
        page.non_field_errors = errors

        errors += format_form_error(form)

        if not errors: 
            instance.save()
            response = 'Saved successfully'
            return HttpResponse(response_success(route=base_url + second_base, response=response))

        else: 
            return HttpResponse(response_error(response=[errors]))

    #render to browser
    return render_to_response(
        template,
        {'s': s, 'form': form, 'page': page, 'table': table, 'obj': obj, 'settings': obj_settings},
        context_instance=RequestContext(request)
    )
开发者ID:pukonu,项目名称:estate,代码行数:96,代码来源:privilege.py

示例7: user_class

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def user_class(request, pk=None, method=None):

    s = Auth().is_auth(request)
    if not s: 
        return Auth.routeLogin

    second_base = 'user_class/'

    page = Page(request)
    page.title = 'User Class'
    page.icon = 'glyphicons glyphicons-parents'
    page.form_name = 'applicationUserClass'
    page.breadcrumbs = ['Privileges', 'User Class']
    errors = []

    obj_list = UserClass.objects.filter(status__exact=1)

    #search logic
    q = request.GET.get('q')
    if q: 
        search_query = get_query(q, ['name'])
        obj_list = obj_list.filter(search_query)

    #build pagination
    page, obj = paginate(page, obj_list, request, q)

    #login url processing
    if method is None or method == 'index': 
        instance = UserClass()
        form = forms.FormUserClass()
        template = base_template + 'list.html'
    elif pk is not None: 
        instance = UserClass.objects.get(pk=pk)
        form = forms.FormUserClass(instance=instance, data=model_to_dict(instance))
        page.form_action = base_url + second_base + 'update/'+str(pk)+'/'
        template = base_template + 'manage.html'
    else: 
        instance = UserClass()
        form = forms.FormUserClass(instance=instance)
        page.form_action = base_url + second_base + 'new/'
        template = base_template + 'manage.html'

    obj_settings = [
        {'link': base_url+second_base+'update/', 'icon': ActionButton.edit},
        {'link': base_url+'user_class-delete/', 'icon': ActionButton.delete},
    ]

    table = Table()
    table.cols = ['Module', 'Name', 'Privilege', 'Users']
    table.rows = []
    for val in obj: 

        # fetch privileges
        tmp = val.user_class_users.filter(sys=request.session['sys'], lid=request.session['lid'])[: 25]
        assoc_users = ""
        for x in tmp: 
            assoc_users += "<a href='#"+base_url+"uc_user-delete/%s/' class='text-danger'>%s</a>, " % \
                           (x.id, "%s [%s %s]" % (x.user.username, x.user.profile.firstname, x.user.profile.lastname))

        # fetch associated users
        tmp = val.user_class_privilege.all()
        assoc = ""
        for x in tmp: 
            assoc += "<a href='#"+base_url+"flush/%s/' class='text-danger'>%s</a><br/>" % (x.id, x.manifest.name)

        table.rows.append({
            'id': val.id,
            'fields': [
                {'field': val.module.name},
                {'field': val.name},
                {'field': assoc},
                {'field': assoc_users}
            ]
        })

    # CREATE & UPDATE
    if request.method == "POST": 

        form = forms.FormUserClass(request.POST, instance=instance)
        if form.is_valid(): 
            #do method to process
            posts = request.POST
            for post in posts: 
                if hasattr(instance, post): 
                    setattr(instance, post, form.cleaned_data[post])

        # non field specific errors
        page.non_field_errors = errors

        errors += format_form_error(form)

        if not errors: 
            instance.save()
            response = 'Saved successfully'
            return HttpResponse(response_success(route=base_url + second_base, response=response))

        else: 
            return HttpResponse(response_error(response=[errors]))

    #render to browser
#.........这里部分代码省略.........
开发者ID:pukonu,项目名称:estate,代码行数:103,代码来源:privilege.py

示例8: User

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def User(request):
    s = Auth().isAuth(request)
    if s is False:
        return Auth.routeLogin

    second_base_url = ''

    page = Page(request)
    page.title = 'User Management'
    page.icon = 'fa fa-group'
    page.breadcrumbs = ['User Management', 'View']
    page.errors = []

    obj = Users.objects.all()
    obj_settings = [
        {'link': base_url_admin+second_base_url+'update/', 'icon': Actions().Icon.edit},
        {'link': base_url_admin+second_base_url+'delete/', 'icon': Actions().Icon.delete},
    ]

    table = Table()
    table.cols = ['Picture', 'Username', 'User Type', 'Profile Name', 'Active', 'Reset Password']
    table.rows = []
    for val in obj:
        reset_link = "<a href='/system/users/reset-password/%s/' class='btn btn-xs btn-warning'>Reset Password</a>" % \
                     val.id

        if val.active == 0:
            btn_class = 'btn-success'
            btn_name = 'Activate'
            btn_link = '/system/users/status/activate/%s/' % val.id
        else:
            btn_class = 'btn-danger'
            btn_name = 'Deactivate'
            btn_link = '/system/users/status/deactivate/%s/' % val.id

        activate_link = "<a href='%s' class='btn btn-xs %s'>%s</a>" % (btn_link, btn_class, btn_name)

        try:
            picture_url = val.picture.url_128x128
            picture_obj = "<img src='%s' height='80' />" % picture_url
        except AttributeError:
            picture_url = ""
            picture_obj = "<img src='%s' height='80' />" % picture_url

        table.rows.append({
            'id': val.id,
            'fields':  [
                {'field': picture_obj},
                {'field': val.username},
                {'field': val.usertype},
                {'field': val.get_fullname()},
                {'field': activate_link},
                {'field': reset_link}
            ]
        })

    return Auth.routeLogin if s is False else \
        render_to_response(
            base_template_admin+'list.html',
            {'s': s, 'table': table, 'settings': obj_settings, 'page': page},
            context_instance=RequestContext(request)
        )
开发者ID:pukonu,项目名称:doas,代码行数:64,代码来源:views.py

示例9: UserManage

# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import breadcrumbs [as 别名]
def UserManage(request, pk=None):

    s = Auth().isAuth(request)
    if s is False:
        return Auth.routeLogin

    second_base_url = ''

    obj = Users() if pk is None else Users.objects.get(pk=pk)

    page = Page(request)
    page.title = 'User Management'
    page.icon = 'fa fa-group'
    page.form_name = 'user_management'
    page.form_action = base_url_admin+second_base_url+'new/'
    page.breadcrumbs = ['System', 'User Management']
    page.errors = []

    # create record
    if request.method != "POST" and pk is None:
        page.breadcrumbs.append('New')
        form = FormRegisterNew(instance=obj)

        return Auth.routeLogin if s is False else \
            render_to_response(
                base_template_admin+'manage.html',
                {'s': s, 'form': form, 'page': page},
                context_instance=RequestContext(request)
            )

    elif request.method != "POST" and pk is not None:
        page.form_action = base_url_admin + second_base_url + 'update/' + str(pk) + '/'
        page.title = 'Update User: %s' % obj.username
        page.breadcrumbs.append('Update')
        page.request = request
        page.id = pk

        from django.forms.models import model_to_dict
        form = FormRegister(instance=obj, data=model_to_dict(obj))

        return render_to_response(
            base_template_admin+'manage.html',
            {'s': s, 'form': form, 'page': page},
            context_instance=RequestContext(request)
        )

    # process record
    elif request.method == "POST":
        page.breadcrumbs.append('Update')
        page.form_action = base_url_admin+second_base_url + 'new/' if pk is None else \
            base_url_admin+second_base_url + 'update/'+str(pk)+'/'

        try:
            raw_password = request.POST["password"]
        except KeyError:
            raw_password = None
            
        # do some non field specific validations
        if pk is None:
            form = FormRegisterNew(request.POST, request.FILES, instance=obj)
            if raw_password == "":
                page.non_field_errors = ['Please enter a valid password']
        else:
            form = FormRegister(request.POST, request.FILES, instance=obj)

        # validate and process
        if form.is_valid() and not page.non_field_errors:
            # do method to process
            posts = request.POST

            for post in posts:
                if hasattr(obj, post):
                    setattr(obj, post, form.cleaned_data[post])

            try:
                if request.FILES['picture']:
                    # delete any previous image
                    try:
                        # get actual file name
                        ext = '.' + obj.picture.url.split('.')[-1]
                        filename = "".join(obj.picture.url.split('.')[:-1])
                        fn = list()
                        fn.append(settings.MEDIA_ROOT + '/' + filename + ext)
                        fn.append(settings.MEDIA_ROOT + '/' + filename + '.64x64' + ext)
                        fn.append(settings.MEDIA_ROOT + '/' + filename + '.128x128' + ext)
                        fn.append(settings.MEDIA_ROOT + '/' + filename + '.256x256' + ext)
                        fn.append(settings.MEDIA_ROOT + '/' + filename + '.512x512' + ext)
                        fn.append(settings.MEDIA_ROOT + '/' + filename + '.1024x1024' + ext)

                        for f in fn:
                            os.path.exists(f) and os.remove(f)

                    except (KeyError, AttributeError, ValueError):
                        pass
            except KeyError:
                pass

            # encrypt password
            if raw_password:
                obj.password = sha1(raw_password).hexdigest()
#.........这里部分代码省略.........
开发者ID:pukonu,项目名称:doas,代码行数:103,代码来源:views.py


注:本文中的packages.bin.bin.Page.breadcrumbs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。