當前位置: 首頁>>代碼示例>>Python>>正文


Python Page.obj方法代碼示例

本文整理匯總了Python中packages.bin.bin.Page.obj方法的典型用法代碼示例。如果您正苦於以下問題:Python Page.obj方法的具體用法?Python Page.obj怎麽用?Python Page.obj使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在packages.bin.bin.Page的用法示例。


在下文中一共展示了Page.obj方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: login

# 需要導入模塊: from packages.bin.bin import Page [as 別名]
# 或者: from packages.bin.bin.Page import obj [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.obj方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。