コード例 #1
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def home(request):

    params = {}
    params["time"] = datetime.now().strftime("%H:%M:%S")
    params["date"] = datetime.now().strftime("%Y-%m-%d")

    params["author"] = "STRATEG"

    lst = []

    for i in xrange(1, 20):
        lst.append({"index": i})

    params["items"] = lst

    params["static"] = "static/"

    params["title"] = "Test title"

    params["error"] = ""

    params["path"] = ""

    # params.update(csrf(request))
    params["csrftoken"] = csrf(request)["csrf_token"]
    return render_to_response("index.html", params)
コード例 #2
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def registration(request):
    context = {}
    if request.method == "POST":
        post_data = request.POST
        username = post_data.get('username', '')
        password = post_data.get('password', '')
        email = post_data.get('email', '')
        first_name = post_data.get('first_name', '')
        last_name = post_data.get('last_name', '')

        User.objects.create_user(username,
                                 email,
                                 password,
                                 first_name=first_name,
                                 last_name=last_name)

        return HttpResponseRedirect("/")

    else:
        form = forms.RegistrationForm()
        context['form'] = form

    context['title'] = "Login"
    context.update(csrf(request))

    return render_to_response("accounts/registration.html", context)
コード例 #3
0
def home(request):

    params = {}
    params['time'] = (datetime.now().strftime('%H:%M:%S'))
    params['date'] = (datetime.now().strftime('%Y-%m-%d'))

    params['author'] = 'STRATEG'

    lst = []

    for i in xrange(1, 20):
        lst.append({"index": i})

    params['items'] = lst

    params['static'] = 'static/'

    params['title'] = "Test title"

    params['error'] = ""

    params['path'] = ''

    # params.update(csrf(request))
    params["csrftoken"] = csrf(request)["csrf_token"]
    return render_to_response('index.html', params)
コード例 #4
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def profile(request):
    if request.user.is_authenticated():
        context = {'user': '******'}
    else:
        context = {'user': '******'}

    context.update(csrf(request))

    return render_to_response("accounts/profile.html", context)
コード例 #5
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def profile(request):
    if request.user.is_authenticated():
        context = {'user': '******'}
    else:
        context = {'user': '******'}

    context.update(csrf(request))

    return render_to_response("accounts/profile.html", context)
コード例 #6
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def login(request):
    context = {}
    if request.method == "POST":
        username = request.POST.get('username', '')
        password = request.POST.get('password', '')
        user = auth.authenticate(username=username, password=password)
        if user is not None and user.is_active:
            # Пароль верный и пользователь активен
            auth.login(request, user)
            # Переадресация на страницу
            return HttpResponseRedirect("/")
        else:
            context['errors'] = 'Incorrect'
            form = forms.LoginForm()
            context['form'] = form
    else:
        form = forms.LoginForm()
        context['form'] = form

    context['title'] = "Login"
    context.update(csrf(request))

    return render_to_response("accounts/login.html", context)
コード例 #7
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def login(request):
    context = {}
    if request.method == "POST":
        username = request.POST.get('username', '')
        password = request.POST.get('password', '')
        user = auth.authenticate(username=username, password=password)
        if user is not None and user.is_active:
            # Пароль верный и пользователь активен
            auth.login(request, user)
            # Переадресация на страницу
            return HttpResponseRedirect("/")
        else:
            context['errors'] = 'Incorrect'
            form = forms.LoginForm()
            context['form'] = form
    else:
        form = forms.LoginForm()
        context['form'] = form

    context['title'] = "Login"
    context.update(csrf(request))

    return render_to_response("accounts/login.html", context)
コード例 #8
0
ファイル: views.py プロジェクト: nmakhotkin/studentrepo
def registration(request):
    context = {}
    if request.method == "POST":
        post_data = request.POST
        username = post_data.get('username', '')
        password = post_data.get('password', '')
        email = post_data.get('email', '')
        first_name = post_data.get('first_name', '')
        last_name = post_data.get('last_name', '')

        User.objects.create_user(username, email, password,
                                 first_name=first_name,
                                 last_name=last_name)

        return HttpResponseRedirect("/")

    else:
        form = forms.RegistrationForm()
        context['form'] = form

    context['title'] = "Login"
    context.update(csrf(request))

    return render_to_response("accounts/registration.html", context)