Commit a75e34d6 authored by wir11cml's avatar wir11cml
Browse files

initial

parents
Pipeline #553 failed with stages
*.sqlite3
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
from django.db import models
# Create your models here.
{% extends 'base_layout.html' %}
{% block content %}
<form class="site-form" action="{% url 'accounts:login' %}" method="post">
{% csrf_token %}
{{form}}
{% if request.GET.next %}
<input type="hidden" name="next" value="{{request.GET.next}}">
{% endif %}
<input type="submit" value="Login">
<br>
<br>
<h3>Not signed up yet? Create an account <a href="{% url 'accounts:signup' %}">here.</a></h3>
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base_layout.html' %}
{% block content %}
<form class="site-form" action="/accounts/signup/" method="post">
{% csrf_token %}
{{form}}
<input type="submit" value="Signup">
</form>
{% endblock %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from . import views
app_name = 'accounts'
urlpatterns = [
url(r'^signup/$', views.signup_view, name="signup"),
url(r'^login/$', views.login_view, name="login"),
url(r'^logout/$', views.logout_view, name="logout"),
]
\ No newline at end of file
from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth import login, logout
# Create your views here.
def signup_view(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
user = form.save()
# login
login(request, user)
return redirect('posts:list')
else:
form = UserCreationForm()
return render(request, 'accounts/signup.html', {'form': form})
def login_view(request):
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
if form.is_valid():
# log in the user
user = form.get_user()
login(request, user)
if 'next' in request.POST:
return redirect(request.POST.get('next'))
else:
return redirect('posts:list')
else:
form = AuthenticationForm()
return render(request, 'accounts/login.html', {'form': form})
def logout_view(request):
if request.method == 'POST':
logout(request)
return redirect('posts:list')
\ No newline at end of file
body{
background-color: #0f121f;
background-image: url(stars.png);
background-repeat-y: no-repeat;
color: #fff;
}
body *{
font-family: Ubuntu;
}
h1, h2, h3, h4, h5{
font-weight: normal;
margin: 0;
}
a, a:hover, a:visited{
color: #fff;
text-decoration: none;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment