[minor] fixed 403s and 404s

This commit is contained in:
Rushabh Mehta 2013-10-02 17:11:51 +05:30
parent 0bc7bfbcf5
commit a2eb9820a0
7 changed files with 18 additions and 14 deletions

View file

@ -353,7 +353,6 @@ _f.Frm.prototype.check_doc_perm = function() {
this.perm = wn.perm.get_perm(dt, dn);
if(!this.perm[0][READ]) {
wn.set_route("403");
return 0;
}
return 1

View file

@ -115,7 +115,9 @@ wn.ui.form.Layout = Class.extend({
});
}
if(df.description) {
$('<div class="col-md-12 small text-muted">' + df.description + '</div>').appendTo(this.section);
$('<div class="col-md-12 small text-muted">' + df.description + '</div>')
.css("padding-left", "40px")
.appendTo(this.section);
}
if(df.label || df.description) {
// spacer

View file

@ -170,7 +170,7 @@ wn.request.cleanup = function(opts, r) {
}
if(r['403']) {
wn.set_route('403');
wn.show_not_permitted(wn.get_route_str());
}
if(r.docs) {

View file

@ -88,7 +88,7 @@ wn.views.Factory = Class.extend({
if(route[1]) {
me.make(route);
} else {
wn.set_route('404');
wn.show_not_found(route);
}
}
},

View file

@ -44,7 +44,7 @@ wn.views.FormFactory = wn.views.Factory.extend({
wn.set_route("Form", dt, new_name)
}
} else {
wn.set_route('404');
wn.show_not_found(route);
}
return;
}

View file

@ -38,7 +38,7 @@ wn.views.pageview = {
wn.views.pageview.with_page(name, function(r) {
if(r && r.exc) {
if(!r['403'])
wn.set_route('404');
wn.show_not_found(name);
} else if(!wn.pages[name]) {
new wn.views.Page(name);
}
@ -59,6 +59,10 @@ wn.views.Page = Class.extend({
wn.pages[window.page_name] = this.wrapper;
} else {
this.pagedoc = locals.Page[this.name];
if(!this.pagedoc) {
wn.show_not_found(name);
return;
}
this.wrapper = wn.container.add_page(this.name);
this.wrapper.label = this.pagedoc.title || this.pagedoc.name;
this.wrapper.page_name = this.pagedoc.name;
@ -89,21 +93,20 @@ wn.views.Page = Class.extend({
}
})
wn.standard_pages["404"] = function() {
var page = wn.container.add_page('404');
wn.show_not_found = function(page_name) {
var page = wn.pages[page_name] || wn.container.add_page(page_name);
$(page).html('<div class="appframe col-md-12">\
<h3><i class="icon-exclamation-sign"></i> '+wn._('Not Found')+'</h3><br>\
<p>'+wn._('Sorry we were unable to find what you were looking for.')+'</p>\
<p><a href="#">'+wn._('Go back to home')+'</a></p>\
</div>');
};
}
wn.standard_pages["403"] = function() {
var page = wn.container.add_page('403');
wn.show_not_permitted = function(page_name) {
var page = wn.pages[page_name] || wn.container.add_page(page_name);
$(page).html('<div class="appframe col-md-12">\
<h3><i class="icon-minus-sign"></i> '+wn._('Not Permitted')+'</h3><br>\
<p>'+wn._('Sorry you are not permitted to view this page.')+'.</p>\
<p><a href="#">'+wn._('Go back to home')+'</a></p>\
</div>');
};
}

View file

@ -10,7 +10,7 @@ wn.views.ReportFactory = wn.views.Factory.extend({
wn.views.ReportViewPage = Class.extend({
init: function(doctype, docname) {
if(!wn.model.can_get_report(doctype)) {
wn.set_route("403");
wn.show_not_permitted(wn.get_route_str());
return;
};