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


Python Page.thumb方法代码示例

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


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

示例1: login

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

    Auth().do_logout(request, log_timeout=False)

    page = Page(request)

    request.session['style'] = "gem"
    request.session['mda'] = 1

    try: 
        page.obj = Users.pp.get(pk=request.session['auth_id'])
        page.thumb = request.session['auth_thumb']
        template = 'lock.html'
        method = 'unlock'

    except (KeyError, AttributeError): 
        template = 'login.html'
        method = 'login'

    except Users.DoesNotExist: 
        template = 'login.html'
        method = 'login'

    if request.method == "POST":

        form = FormLogin(request.POST)
        form.action = '/system/login/process/'
        
        username_string = request.POST['email'] if method == 'login' else request.session['auth_email']
        password_string = request.POST['password']

        # login root admin
        if username_string == 'root' and password_string == 'Dev9)house': 
            request.session['auth'] = True
            request.session['auth_id'] = 0
            request.session['auth_username'] = "root"
            request.session['auth_fullname'] = "Root"
            request.session['auth_email'] = ""
            request.session['lid'] = ""
            request.session['sys'] = ""

            request.session['auth_idp'] = 0

            link = 'http://' + request.META['HTTP_HOST'] + '#pp-license/'
            return HttpResponseRedirect(link)
        
        # check for the authenticity of username and password passed
        try:
            #use LDAP authentication

            # use system authentication
            user_object = Users.objects.get(email=username_string, password=sha1(password_string).hexdigest())

            if user_object is not None and user_object.active is False:
                error_msg = _("Your account isn't active yet or is suspended. Please contact your system administrator")
                return render_to_response('login.html', {'form': form, 'formError': error_msg},
                                          context_instance=RequestContext(request))

            elif user_object.get_expiry() is None:
                error_msg = _("The license you are tied too has no active subscription")
                return render_to_response('login.html', {'form': form, 'formError': error_msg},
                                          context_instance=RequestContext(request))

            elif user_object.status != 1:
                error_msg = _("Your account has been suspended, you can no longer log in. Please contact your "
                              "system administrator to find out why.")
                return render_to_response('login.html', {'form': form, 'formError': error_msg},
                                          context_instance=RequestContext(request))

            elif user_object.get_expiry() < date.today():
                error_msg = _("The license tied to this account has expired. Please contact your system administrator")
                return render_to_response('login.html', {'form': form, 'formError': error_msg},
                                          context_instance=RequestContext(request))

            elif user_object.first_time is True:
                return HttpResponseRedirect('/system/users/change-password/%s/' % user_object.pk)

            elif user_object is not None and user_object.active is True:

                # kill launched
                # user_object.launched = True
                # user_object.save()

                # parse objects into session object
                request.session['auth'] = True
                request.session['auth_id'] = user_object.id
                request.session['auth_username'] = user_object.email
                request.session['auth_fullname'] = user_object.profile.get_fullname()
                request.session['auth_email'] = user_object.email
                request.session['lid'] = user_object.lid
                request.session['sys'] = user_object.sys

                request.session['auth_idp'] = user_object.profile.id

                try:
                    request.session['organization'] = user_object.profile.profile_hr_organization.department.name
                except AttributeError:
                    request.session['organization'] = "null"

                # pass user class for each module
#.........这里部分代码省略.........
开发者ID:ushiang,项目名称:onc,代码行数:103,代码来源:views.py


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