diff --git a/amadeus/templates/base.html b/amadeus/templates/base.html new file mode 100644 index 0000000..561436c --- /dev/null +++ b/amadeus/templates/base.html @@ -0,0 +1,151 @@ + + +{% load static i18n %} +{% load static i18n permission_tags %} +{% get_current_language as LANGUAGE_CODE %} + + + + {{ title }} | Amadeus + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% with "js/vendor/locales/bootstrap-datepicker."|add:LANGUAGE_CODE|add:".js" as locale_datepicker %} + + {% endwith %} + + + + + + + + + + + + + {% block style %} + {% endblock %} + {% block javascript %} + {% endblock %} + + + + + + + + {% block nav %} + + {% endblock %} +
+
+
+ {% block test %} + {% endblock %} + {% block sidebar %} + {% endblock %} +
+
+ {% block breadcrumbs %}{% endblock %} + {% block render_breadcrumbs %}{% endblock %} +
+
+ {% block content %}{% endblock %} +
+
+
+ + {% block script_file %} + + {% endblock script_file %} + + {% block script_link %} + + {% endblock script_link %} + + + + + + \ No newline at end of file diff --git a/amadeus/urls.py b/amadeus/urls.py index b437abb..7fd4012 100644 --- a/amadeus/urls.py +++ b/amadeus/urls.py @@ -19,6 +19,7 @@ from django.conf.urls import include, url from django.conf.urls.static import static from django.contrib import admin + urlpatterns = [ url(r'^users/', include('users.urls', namespace = 'users')), url(r'^admin/', admin.site.urls), diff --git a/users/templates/users/login.html b/users/templates/users/login.html new file mode 100644 index 0000000..f09d692 --- /dev/null +++ b/users/templates/users/login.html @@ -0,0 +1,81 @@ +{% extends 'base.html' %} + +{% load static i18n %} +{% load widget_tweaks %} + +{% block nav %} +{% endblock %} + +{% block sidebar %} +{% endblock sidebar %} + +{% block content %} +
+
+
+ +
+
+
+ +
+
+ {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %} +
+
+
+
+

{% trans 'Sign in with your account to continue' %}

+
+
+
+ {% csrf_token %} +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ +
+ +
+ +
+
+ {% trans 'Sign Up' %} +
+
+ +{% endblock%} \ No newline at end of file diff --git a/users/urls.py b/users/urls.py index 6153998..86755d4 100644 --- a/users/urls.py +++ b/users/urls.py @@ -4,7 +4,8 @@ from . import views urlpatterns = [ - url(r'^$', views.UsersListView.as_view(), name='manage'), + url(r'^login/$', views.login, name='login'), + #url(r'^$', views.UsersListView.as_view(), name='manage'), url(r'^create/$', views.Create.as_view(), name='create'), url(r'^edit/(?P[\w_-]+)/$', views.Update.as_view(), name='update'), url(r'^view/(?P[\w_-]+)/$', views.View.as_view(), name='view'), diff --git a/users/views.py b/users/views.py index e0647c0..3cf4aa4 100644 --- a/users/views.py +++ b/users/views.py @@ -221,6 +221,25 @@ class SearchView(LoginRequiredMixin, generic.ListView): return context +def login(self, request): + context = {} + context['title'] = 'Log In' + + if request.POST: + username = request.POST['username'] + password = request.POST['password'] + user = authenticate(username=username, password=password) + if user is not None: + login_user(request, user) + return redirect(reverse("users:login")) + else: + messages.add_message(request, messages.ERROR, _('E-mail or password are incorrect.')) + context["username"] = username + elif request.user.is_authenticated: + return redirect(reverse('users:login')) + + return render(request,"index.html",context) + # API VIEWS class UserViewSet(viewsets.ModelViewSet): -- libgit2 0.21.2