示例#1
0
 def method_not_allowed_page(*args, **kwargs):
     """
     The method specified in the Request-Line is not allowed for the
     resource
     identified by the Request-URI. The response MUST include an
     Allow header
     containing a list of valid methods for the requested resource.
     """
     return render_template("errors/method_not_allowed.html"), 405
示例#2
0
 def __call__(self, *args, **kwargs):
     html = super(PrepopulatedText, self).__call__(*args, **kwargs)
     slave = args[0].id
     if self.master:
         html += render_template('admin/custom/prepopulated.html',
                                 theme=current_app.config.get(
                                     'ADMIN_THEME', 'admin'),
                                 master=self.master,
                                 slave=slave)
     return html
示例#3
0
def login():
    form = LoginForm()
    if request.method == 'POST' and form.validate_on_submit():
        user = db.users.find_one({"_id": form.username.data})
        if user and User.validate_login(user['password'], form.password.data):
            user_obj = User(user['_id'])
            login_user(user_obj, remember=True)
            flash("Logged in successfully!", category='success')
            return redirect(request.args.get("next") or url_for("admin.index"))
        flash("Wrong username or password!", category='error')
    return render_template('login.html', title='login', form=form)
示例#4
0
 def forbidden_page(*args, **kwargs):
     """
     The server understood the request, but is refusing to fulfill it.
     Authorization will not help and the request SHOULD NOT be repeated.
     If the request method was not HEAD and the server wishes to make public
     why the request has not been fulfilled, it SHOULD describe the
     reason for
     the refusal in the entity. If the server does not wish to make this
     information available to the client, the status code 404 (Not Found)
     can be used instead.
     """
     return render_template("errors/access_forbidden.html"), 403
示例#5
0
 def __call__(self, field, **kwargs):
     c = kwargs.pop('class', '') or kwargs.pop('class_', '')
     kwargs['class'] = u'%s %s' % (self.css_cls, c)
     kwargs['rows'] = self.rows
     kwargs['cols'] = self.cols
     s = kwargs.pop('style', '') or kwargs.pop('style_', '')
     kwargs['style'] = u"%s %s" % (self.style_, s)
     html = super(TextEditor, self).__call__(field, **kwargs)
     html += render_template('admin/texteditor/%s.html' % self.editor,
                             theme=current_app.config.get(
                                 'ADMIN_THEME', 'admin'),
                             selector='.' + self.css_cls)
     return html
示例#6
0
 def page_not_found(*args, **kwargs):
     """
     The server has not found anything matching the Request-URI.
     No indication
     is given of whether the condition is temporary or permanent.
     The 410 (Gone)
     status code SHOULD be used if the server knows, through some internally
     configurable mechanism, that an old resource is permanently unavailable
     and has no forwarding address. This status code is commonly used when
     the
     server does not wish to reveal exactly why the request has been
     refused,
     or when no other response is applicable.
     """
     return render_template("errors/page_not_found.html"), 404
示例#7
0
 def server_error_page(*args, **kwargs):
     return render_template("errors/server_error.html"), 500