@@ -4,7 +4,7 @@ from frappe import _ | |||||
from frappe.utils import now_datetime, getdate, flt, cint, get_fullname | from frappe.utils import now_datetime, getdate, flt, cint, get_fullname | ||||
from frappe.installer import update_site_config | from frappe.installer import update_site_config | ||||
from frappe.utils.data import formatdate | from frappe.utils.data import formatdate | ||||
from frappe.utils.user import get_enabled_system_users | |||||
from frappe.utils.user import get_enabled_system_users, get_system_managers | |||||
import os, subprocess, urlparse, urllib | import os, subprocess, urlparse, urllib | ||||
class SiteExpiredError(frappe.ValidationError): | class SiteExpiredError(frappe.ValidationError): | ||||
@@ -16,13 +16,23 @@ def check_if_expired(): | |||||
"""check if account is expired. If expired, do not allow login""" | """check if account is expired. If expired, do not allow login""" | ||||
if not has_expired(): | if not has_expired(): | ||||
return | return | ||||
# if expired, stop user from logging in | |||||
expires_on = formatdate(get_limits().get("expiry")) | |||||
support_email = get_limits().get("support_email") or _("your provider") | |||||
frappe.throw(_("""Your subscription expired on {0}. | |||||
To extend please send an email to {1}""").format(expires_on, support_email), | |||||
SiteExpiredError) | |||||
limits = get_limits() | |||||
expires_on = formatdate(limits.get("expiry")) | |||||
support_email = limits.get("support_email") | |||||
if limits.upgrade_link: | |||||
upgrade_link = get_upgrade_link(limits.upgrade_link) | |||||
upgrade_link = '<a href="{upgrade_link}" target="_blank">{click_here}</a>'.format(upgrade_link=upgrade_link, click_here=_('click here')) | |||||
message = _("""Your subscription expired on {0}. To extend your subscription, {1}.""").format(expires_on, upgrade_link) | |||||
elif support_email: | |||||
message = _("""Your subscription expired on {0}. To extend your subscription, please send an email to {1}.""").format(expires_on, support_email) | |||||
else: | |||||
message = _("""Your subscription expired on {0}""").format(expires_on) | |||||
frappe.throw(message, SiteExpiredError) | |||||
def has_expired(): | def has_expired(): | ||||
if frappe.session.user=="Administrator": | if frappe.session.user=="Administrator": | ||||
@@ -954,12 +954,6 @@ body { | |||||
.content-header { | .content-header { | ||||
padding-bottom: 20px; | padding-bottom: 20px; | ||||
} | } | ||||
a:hover, | |||||
a:visited, | |||||
a:link, | |||||
a:active { | |||||
text-decoration: none; | |||||
} | |||||
.footer-group-label { | .footer-group-label { | ||||
display: inline-block; | display: inline-block; | ||||
font-size: 11px; | font-size: 11px; | ||||
@@ -258,8 +258,8 @@ fieldset { | |||||
// margin-top:30px; | // margin-top:30px; | ||||
margin-bottom:30px; | margin-bottom:30px; | ||||
.title{ | .title{ | ||||
font-size: 14px; | |||||
font-weight: bold; | |||||
font-size: 14px; | |||||
font-weight: bold; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -281,7 +281,7 @@ fieldset { | |||||
.no-results { | .no-results { | ||||
text-align: center; | text-align: center; | ||||
.octicon-telescope { | .octicon-telescope { | ||||
display: block; | display: block; | ||||
padding: 10px; | padding: 10px; | ||||
@@ -565,11 +565,6 @@ a.active { | |||||
padding-bottom:20px; | padding-bottom:20px; | ||||
} | } | ||||
a:hover, a:visited, a:link, a:active | |||||
{ | |||||
text-decoration: none; | |||||
} | |||||
.footer-group-label { | .footer-group-label { | ||||
display:inline-block; | display:inline-block; | ||||
font-size: 11px; | font-size: 11px; | ||||
@@ -660,4 +655,4 @@ li .footer-child-item { | |||||
font-weight: 500; | font-weight: 500; | ||||
margin-top: -10px; | margin-top: -10px; | ||||
margin-right: -8px; | margin-right: -8px; | ||||
} | |||||
} |
@@ -78,16 +78,11 @@ login.signup = function() { | |||||
// Login | // Login | ||||
login.call = function(args) { | login.call = function(args) { | ||||
frappe.freeze(); | |||||
$.ajax({ | |||||
return frappe.call({ | |||||
type: "POST", | type: "POST", | ||||
url: "/", | |||||
data: args, | |||||
dataType: "json", | |||||
args: args, | |||||
freeze: true, | |||||
statusCode: login.login_handlers | statusCode: login.login_handlers | ||||
}).always(function(){ | |||||
frappe.unfreeze(); | |||||
}); | }); | ||||
} | } | ||||
@@ -97,8 +92,19 @@ login.login_handlers = (function() { | |||||
if(xhr.responseJSON) { | if(xhr.responseJSON) { | ||||
data = xhr.responseJSON; | data = xhr.responseJSON; | ||||
} | } | ||||
var message = data._server_messages | |||||
? JSON.parse(data._server_messages).join("\n") : default_message; | |||||
var message = default_message; | |||||
if (data._server_messages) { | |||||
message = ($.map(JSON.parse(data._server_messages || '[]'), function() { | |||||
// temp fix for messages sent as dict | |||||
try { | |||||
return JSON.parse(v).message; | |||||
} catch (e) { | |||||
return v; | |||||
} | |||||
}) || []).join('<br>') || default_message; | |||||
} | |||||
frappe.msgprint(message); | frappe.msgprint(message); | ||||
}; | }; | ||||
} | } | ||||
@@ -39,7 +39,7 @@ $.extend(frappe, { | |||||
data: opts.args, | data: opts.args, | ||||
dataType: "json", | dataType: "json", | ||||
headers: { "X-Frappe-CSRF-Token": frappe.csrf_token }, | headers: { "X-Frappe-CSRF-Token": frappe.csrf_token }, | ||||
statusCode: { | |||||
statusCode: opts.statusCode || { | |||||
404: function(xhr) { | 404: function(xhr) { | ||||
frappe.msgprint(__("Not found")); | frappe.msgprint(__("Not found")); | ||||
}, | }, | ||||