Commit 6f5e6be1 authored by alexandre's avatar alexandre

registration + dependencies upgrades. Run migrations

parent 04ee7773
......@@ -33,6 +33,11 @@ INSTALLED_APPS = [
'taggit',
'taggit_serializer',
'django.contrib.sites',
'allauth',
'allauth.account',
'rest_auth.registration',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
......@@ -74,6 +79,7 @@ TEMPLATES = [
WSGI_APPLICATION = 'organon.wsgi.application'
SITE_ID = 1
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
......@@ -143,6 +149,8 @@ COMPRESS_CSS_FILTERS = [
'compressor.filters.cssmin.CSSMinFilter'
]
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL = "/compte"
try:
LOCAL_SETTINGS
......
......@@ -21,6 +21,9 @@ from django.conf import settings
from rest_framework import routers
from playground import views
# from django.views.generic.base import TemplateView
from allauth.account.views import ConfirmEmailView
router = routers.DefaultRouter()
router.register(r'attachments', views.AttachmentViewSet)
......@@ -33,6 +36,9 @@ urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + [
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', ConfirmEmailView.as_view(),
name='account_confirm_email'),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^', include('playground.urls')),
......
......@@ -173,41 +173,74 @@ section.hidden { display: none; }
Modal windows
========================================================================== */
.modalDialog {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 99999;
transition: opacity 400ms ease-in;
.modal-dialog {
display: flex;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 99999;
transition: opacity 400ms ease-in;
justify-content: center;
align-items: center;
}
.modalDialog > div {
.modal-dialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
padding: 8px;
background: #fff;
color: black;
}
.close {
background: #606061;
color: #ffffff;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
border-radius: 12px;
box-shadow: 1px 1px 3px #000;
/* .close { */
/* background: #606061; */
/* color: #ffffff; */
/* line-height: 25px; */
/* position: absolute; */
/* right: -12px; */
/* text-align: center; */
/* top: -10px; */
/* width: 24px; */
/* text-decoration: none; */
/* font-weight: bold; */
/* border-radius: 12px; */
/* box-shadow: 1px 1px 3px #000; */
/* } */
/* .close:hover { background: #00d9ff; } */
.modal-dialog label { display: none; }
.modal-dialog input[type="email"],
.modal-dialog input[type="text"],
.modal-dialog input[type="password"],
.modal-dialog input[type="submit"] {
padding: 0;
margin: 0;
font-size: inherit;
font-family: inherit;
background: none;
border: none;
}
.modal-dialog input[type="submit"] {
text-decoration: underline;
}
.close:hover { background: #00d9ff; }
.modal-dialog h2 {
margin-bottom: 1em;
}
.modal-dialog input[type="email"],
.modal-dialog input[type="text"],
.modal-dialog input[type="password"] {
border-bottom: 2px solid;
padding-bottom: 6px;
margin-bottom: 18px;
}
......@@ -971,3 +1004,7 @@ li li li li li li li li li li li li li li form { color: var(--color-14); }
.permission-list label { display: inline; }
.errors {
color: rgb(202, 027, 027);
}
......@@ -9,11 +9,23 @@ window.W = window.W || {};
W.ScoreApp = new Backbone.Marionette.Application({
region: 'body',
triggers: {
keydown: 'keydown'
},
onStart: function(options) {
var userAuthModel = new W.UserAuthModel();
this.showView(new W.BaseView({model: userAuthModel}));
var baseView = new W.BaseView({model: userAuthModel});
this.showView(baseView);
userAuthModel.fetch();
// hide modals when typing escape
$(document).on("keydown", function(event) {
if (event.keyCode == 27) {
baseView.hideModal();
}
})
var router = new W.ScoreRouter({application: this});
$(document).on("click", "a", function(e) {
......
......@@ -12,8 +12,8 @@ window.W = window.W || {};
'apropos(/)': 'about',
'partitions(/)': 'scoreList',
'partitions/:id(/)': 'scoreDetail',
'users/(/)': 'userList',
'users/:id(/)': 'userDetail',
'users(/)': 'userList',
'compte(/)': 'userDetail',
},
initialize: function (options) {
......
......@@ -1912,8 +1912,10 @@ window.W = window.W || {};
});
W.LoginView = Backbone.Marionette.View.extend({
template: '#login-template',
W.BaseModalView = Backbone.Marionette.View.extend({
attributes : {
class: 'modal-dialog',
},
ui: {
'close': '.btn-close',
......@@ -1924,6 +1926,11 @@ window.W = window.W || {};
'click @ui.close': 'hide:modal',
'click @ui.submit': 'submit',
},
});
W.LoginView = W.BaseModalView.extend({
template: '#login-template',
onSubmit: function (foo, event) {
event.preventDefault();
......@@ -1932,7 +1939,6 @@ window.W = window.W || {};
var that = this;
var form = this.$el.find("form");
var data = form.serialize();
$.ajax({
type: "POST",
......@@ -1950,24 +1956,15 @@ window.W = window.W || {};
});
W.LogoutView = Backbone.Marionette.View.extend({
W.LogoutView = W.BaseModalView.extend({
template: '#logout-template',
ui: {
'close': '.btn-close',
'submit': '.btn-submit'
},
triggers: {
'click @ui.close': 'hide:modal',
'click @ui.submit': 'submit'
},
onSubmit: function (foo, event) {
event.preventDefault();
var that = this;
var that = this;
var model = this.model;
var form = this.$el.find("form");
$.ajax({
......@@ -1975,29 +1972,49 @@ window.W = window.W || {};
url: form.attr('action'),
success: function(data, textStatus, jqXHR){
that.trigger('hide:modal');
alert("ok");
model.set(model.defaults);
},
error: function(xhr, ajaxOptions, thrownError){
alert('logout failed - please try again');
// that.trigger('hide:modal');
// model.clear();
},
});
}
});
W.RegisterView = Backbone.Marionette.View.extend({
W.RegisterView = W.BaseModalView.extend({
template: '#register-template',
ui: {
'close': '.btn-close'
templateContext: {
errors: undefined
},
triggers: {
'click @ui.close': 'hide:modal',
},
onSubmit: function (foo, event) {
event.preventDefault();
var that = this;
var model = this.model;
var form = this.$el.find("form");
$.ajax({
type: "POST",
url: form.attr('action'),
data: form.serialize(),
success: function(data, textStatus, jqXHR){
that.trigger('hide:modal');
model.set(model.defaults);
},
error: function(xhr, ajaxOptions, thrownError){
if (xhr.status == 400) {
that.templateContext.errors = xhr.responseJSON;
that.render();
that.templateContext.errors = undefined;
};
},
});
}
});
......@@ -2196,7 +2213,7 @@ window.W = window.W || {};
},
hideModal: function(event) {
this.detachChildView('modal');
this.getRegion('modal').reset();
},
});
})();
......@@ -11,20 +11,16 @@
<div class="content">
<nav>
<% if (username) { %>
<%- t('Bienvenue') %><a href="/users/<%- pk %>"><%- username %></a>
<% } else { %>
<%- t('Bienvenue') %> anonymous
<%- t('Bienvenue') %> <a href="/compte"><%- username %></a>
<% } %>
<ul>
<% if (username) { %>
<li><a href="#" class="btn-logout"><%- t('Se déconnecter') %></a></li>
<li><a href="#" class="btn-logout"><%- t('se déconnecter') %></a></li>
<% } else { %>
<li><a href="#" class="btn-login"><%- t('Se connecter') %></a></li>
<li><a href="#" class="btn-register"><%- t('S\'inscrire') %></a></li>
<li><a href="#" class="btn-login"><%- t('se connecter') %></a> <a href="#" class="btn-register"><%- t('s\'inscrire') %></a></li>
<% } %>
<li><a href="#" class="btn-lang" data-lang="en">en</a></li>
<li><a href="#" class="btn-lang" data-lang="fr">fr</a></li>
<li><a href="#" class="btn-lang" data-lang="en">en</a> <a href="#" class="btn-lang" data-lang="fr">fr</a></li>
</ul>
</nav>
......
<div id="openModal" class="modalDialog">
<div> <a href="#close" title="Close" class="btn-close">X</a>
<div>
<p style="text-align: right; margin-bottom: 1em;">
<a href="#close" title="Close" class="btn-close">fermer</a>
</p>
<h2><%- t('Se connecter') %></h2>
<h2><%- t('Connexion') %></h2>
<form method="post" action="/rest-auth/login/">
<p><label for="id_username">Username:</label> <input autofocus="" id="id_username" maxlength="254" name="username" type="text" required /></p>
<p><label for="id_password">Password:</label> <input id="id_password" name="password" type="password" required /></p>
<input type="submit" class="btn-submit" value="Log in" /><%- t('Se connecter') %>
</form>
</div>
<form method="post" action="/rest-auth/login/">
<p>
<label for="id_username"><%- t('nom d’utilisateur') %></label>
<input autofocus="" id="id_username" maxlength="254" name="username" type="text" required placeholder="<%- t('nom d’utilisateur') %>"/>
</p>
<p>
<label for="id_password"><%- t('mot de passe') %></label>
<input id="id_password" name="password" type="password" required placeholder="<%- t('mot de passe') %>"/>
</p>
<p style="text-align: right; margin-top: 1em">
<input type="submit" class="btn-submit" value="<%- t('se connecter') %>" />
</p>
</form>
</div>
<div id="openModal" class="modalDialog">
<div> <a href="#close" title="Close" class="btn-close">X</a>
<div>
<p style="text-align: right; margin-bottom: 1em;">
<a href="#close" title="Close" class="btn-close">fermer</a>
</p>
<h2><%- t('Etes-vous sur de vouloir vous deconnecter?') %></h2>
<form method="post" action="/rest-auth/logout/">
<p><input class="btn-submit" type="submit" value="ok"></input></p>
</form>
</div>
<p><%- t('Êtes-vous certain de vouloir vous deconnecter?') %></p>
<form method="post" action="/rest-auth/logout/">
<p style="text-align: right; margin-top: 1em">
<input type="submit" class="btn-close" value="<%- t('non') %>" />
<input type="submit" class="btn-submit" value="<%- t('oui') %>" />
</p>
</form>
</div>
<div id="openModal" class="modalDialog">
<div> <a href="#close" title="Close" class="btn-close">X</a>
<h2>Register</h2>
<form method="post" action="">
<input type="hidden" name="csrfmiddlewaretoken" value="DlQBl1CbGROA9YeL2VUa4lOn0d41iyKBJO2qYw469dnJVEJ7KD3XSTUF4tKSYESL">
<p><label for="id_username">Username:</label> <input autofocus="" id="id_username" maxlength="150" name="username" type="text" required=""> <span class="helptext">Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.</span></p>
<p><label for="id_email">Email:</label> <input id="id_email" name="email" type="email" required=""> <span class="helptext">email address</span></p>
<p><label for="id_password1">Password:</label> <input id="id_password1" name="password1" type="password" required=""></p>
<p><label for="id_password2">Password confirmation:</label> <input id="id_password2" name="password2" type="password" required=""> <span class="helptext">Enter the same password as before, for verification.</span></p>
<input type="submit" value="Submit">
</form>
</div>
<div>
<p style="text-align: right; margin-bottom: 1em;">
<a href="#close" title="Close" class="btn-close">fermer</a>
</p>
<h2><%- t('inscription') %></h2>
<% if (errors) { %>
<ul class="errors">
<% for (var field in errors) { %>
<li><%- field %>
<ul>
<% for (var i = 0; i < errors[field].length; i++) { %>
<li><%- errors[field][i] %></li>
<% } %>
</ul>
</li>
<% } %>
</ul>
<% } %>
<form method="post" action="/rest-auth/registration/">
<!-- <input type="hidden" name="csrfmiddlewaretoken" value="DlQBl1CbGROA9YeL2VUa4lOn0d41iyKBJO2qYw469dnJVEJ7KD3XSTUF4tKSYESL"> -->
<p>
<label for="id_username">Username:</label>
<input autofocus="" id="id_username" maxlength="150" name="username" type="text" required="" required placeholder="<%- t('nom d’utilisateur') %>">
<!-- <span class="helptext">Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.</span> -->
</p>
<p>
<label for="id_email">Email:</label>
<input id="id_email" name="email" type="email" required="" required placeholder="<%- t('email') %>">
<!-- <span class="helptext">email address</span> -->
</p>
<p>
<label for="id_password1">Password:</label>
<input id="id_password1" name="password1" type="password" required="" required placeholder="<%- t('mot de passe') %>">
</p>
<p>
<label for="id_password2">Password confirmation:</label>
<input id="id_password2" name="password2" type="password" required="" required placeholder="<%- t('confirmation') %>">
<!-- <span class="helptext">Enter the same password as before, for verification.</span> -->
</p>
<p style="text-align: right; margin-top: 1em">
<input type="submit" class="btn-submit" value="<%- t('s’inscrire') %>" />
</p>
</form>
</div>
django>=1.10,<1.11
django>=1.11,<2
djangorestframework
djangorestframework-recursive
django-rest-auth
......@@ -9,3 +9,4 @@ django-taggit
django-taggit-serializer
django-admin-sortable2
django-guardian
django-allauth
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