# HG changeset patch # User cavaliet # Date 1408465775 -7200 # Node ID eab6629b5b31d8399d3431057ff6aca7a079700e # Parent 88d36ba3f6c9423cbd4a3794c08b8cabae8023b7 ajax login first step diff -r 88d36ba3f6c9 -r eab6629b5b31 src/hdabo/templates/registration/login.html --- a/src/hdabo/templates/registration/login.html Thu Jul 24 16:25:52 2014 +0200 +++ b/src/hdabo/templates/registration/login.html Tue Aug 19 18:29:35 2014 +0200 @@ -13,7 +13,7 @@ {% csrf_token %} {{form.as_p}} - +

 

{% trans "Still not a user ? Create an account" %} diff -r 88d36ba3f6c9 -r eab6629b5b31 src/hdalab/static/hdalab/js/renkan-manual-save.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hdalab/static/hdalab/js/renkan-manual-save.js Tue Aug 19 18:29:35 2014 +0200 @@ -0,0 +1,83 @@ +/* Saves the Full JSON once */ + +Rkns.jsonIOSaveOnClick = function(_renkan, _opts) { + var _proj = _renkan.project, + _saveWarn = false, + _onLeave = function() { + return "Project not saved"; + }; + if (typeof _opts.http_method === "undefined") { + _opts.http_method = 'POST'; + } + var _load = function() { + var getdata = {}, + rx = /id=([^&#?=]+)/, + matches = document.location.hash.match(rx); + if (matches) { + getdata.id = matches[1]; + } + Rkns.$.ajax({ + url: _opts.url, + data: getdata, + success: function(_data) { + _proj.set(_data, {validate: true}); + _renkan.renderer.autoScale(); + } + }); + }; + var _save = function() { + _proj.set("saved_at", new Date()); + var _data = _proj.toJSON(); + Rkns.$.ajax({ + type: _opts.http_method, + url: _opts.url, + contentType: "application/json", + data: JSON.stringify(_data), + success: function(data, textStatus, jqXHR) { + console.log("RMS success !"); + $(window).off("beforeunload", _onLeave); + _saveWarn = false; + //document.location.hash = "#id=" + data.id; + //$(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut(); + } + }); + }; + var _checkLeave = function() { + var title = _proj.get("title"); + if (title && _proj.get("nodes").length) { + $(".Rk-Save-Button").removeClass("disabled"); + } else { + $(".Rk-Save-Button").addClass("disabled"); + } + if (title) { + $(".Rk-PadTitle").css("border-color","#333333"); + } + if (!_saveWarn) { + _saveWarn = true; + $(window).on("beforeunload", _onLeave); + } + }; + _load(); + _proj.on("add:nodes add:edges add:users change", function(_model) { + _model.on("change remove", function(_model) { + _checkLeave(); + }); + _checkLeave(); + }); + _renkan.renderer.save = function() { + console.log("RMS _renkan.renderer.save _opts.user_authenticated = ", _opts.user_authenticated); + if(_opts.user_authenticated==true){ + if ($(".Rk-Save-Button").hasClass("disabled")) { + if (!_proj.get("title")) { + $(".Rk-PadTitle").css("border-color","#ff0000"); + } + } else { + _save(); + } + } + else{ + //$(".Rk-Notifications").text("Connecte-toi bordel !").fadeIn().delay(2000).fadeOut(); + dialog.dialog( "open" ); + } + }; +}; diff -r 88d36ba3f6c9 -r eab6629b5b31 src/hdalab/templates/ajax_identification/ajax_login.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hdalab/templates/ajax_identification/ajax_login.html Tue Aug 19 18:29:35 2014 +0200 @@ -0,0 +1,16 @@ +{% load i18n %} +

+ {% if form.errors %} +

{% trans "Sorry, that's not a valid username or password." %}

+ {% endif %} +
+ {% csrf_token %} + + {{form.as_p}} + +
+

 

+

{% trans "Still not a user ? Create an account" %} +

{% trans "Forgot password ?" %} +

+ diff -r 88d36ba3f6c9 -r eab6629b5b31 src/hdalab/templates/ajax_identification/ajax_login_ok.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hdalab/templates/ajax_identification/ajax_login_ok.html Tue Aug 19 18:29:35 2014 +0200 @@ -0,0 +1,5 @@ +
OK
+
+
  • {{ user.username }}
  • +
  • {% trans "Log out" %}
  • +
    \ No newline at end of file diff -r 88d36ba3f6c9 -r eab6629b5b31 src/hdalab/templates/renkan_edit.html --- a/src/hdalab/templates/renkan_edit.html Thu Jul 24 16:25:52 2014 +0200 +++ b/src/hdalab/templates/renkan_edit.html Tue Aug 19 18:29:35 2014 +0200 @@ -5,6 +5,7 @@ {% block css_import %} {{block.super}} +