Commit dbd4a5cb authored by BERJON Matthieu's avatar BERJON Matthieu

Create accounts application

I created the accounts application and moved everything that was in the
main application related to the login/logout/register there.
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent e6928fdf
from django.conf.urls import url, include
from . import views
app_name = 'account'
urlpatterns = [
# Registration
url(r'^', include('django.contrib.auth.urls')),
url(r'^signup/$', views.SignUp.as_view(), name='signup'),
]
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views.generic import CreateView
class SignUp(CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('account:login')
template_name = 'registration/signup.html'
......@@ -17,8 +17,4 @@ urlpatterns = [
r'^settings/$',
views.UserUpdateView.as_view(),
name='user_settings'),
# Registration
url(r'^auth/', include('django.contrib.auth.urls')),
url(r'^auth/signup/$', views.SignUp.as_view(), name='signup'),
]
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import render
from django.urls import reverse_lazy, reverse
from django.urls import reverse
from django.views.generic import (
CreateView,
ListView,
DetailView,
UpdateView,
......@@ -71,9 +69,3 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
def get_object(self):
# Only get the User record for the user making the request
return AllgoUser.objects.get(user__username=self.request.user.username)
class SignUp(CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('main:login')
template_name = 'registration/signup.html'
......@@ -15,17 +15,17 @@
</li>
{% if not user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'main:login' %}"><i class="fas fa-sign-in-alt"></i> Login</a>
<a class="nav-link" href="{% url 'account:login' %}"><i class="fas fa-sign-in-alt"></i> Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'main:signup' %}"><i class="fas fa-user-plus"></i> Sign up</a>
<a class="nav-link" href="{% url 'account:signup' %}"><i class="fas fa-user-plus"></i> Sign up</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'main:job_list' %}"><i class="fas fa-database"></i> My jobs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'main:logout' %}"><i class="fas fa-sign-out-alt"></i> Sign out</a>
<a class="nav-link" href="{% url 'account:logout' %}"><i class="fas fa-sign-out-alt"></i> Sign out</a>
</li>
{% endif %}
</ul>
......
......@@ -12,5 +12,5 @@
<button class="btn btn-primary" type="submit">Login</button>
</form>
<p><a href="{% url 'main:signup' %}">Register</a> - <a href="{% url 'main:password_reset' %}">Forgot your password?</a></p>
<p><a href="{% url 'account:signup' %}">Register</a> - <a href="{% url 'account:password_reset' %}">Forgot your password?</a></p>
{% endblock %}
......@@ -60,6 +60,7 @@ DJANGO_APPS = [
]
LOCAL_APPS = [
'main',
'accounts',
]
if "ALLGO_ADDITIONAL_APPS" in os.environ:
......
......@@ -10,6 +10,7 @@ urlpatterns = [
# Allgo stuff here
url(r'', include('main.urls')),
url(r'^account/', include('accounts.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
......
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