-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release v 0.1.12.25 and Merry X'mas!
- Loading branch information
imwilsonxu
committed
Dec 24, 2012
1 parent
41b9f1b
commit 7df0de4
Showing
66 changed files
with
646 additions
and
1,043 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ production.py | |
dist | ||
build | ||
logs | ||
|
||
uploads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .views import admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from flask.ext.wtf import Form | ||
from flask.ext.wtf import HiddenField, SubmitField, RadioField, DateField | ||
from flask.ext.wtf import AnyOf | ||
|
||
from ..user import USER_ROLE, USER_STATUS | ||
|
||
|
||
class UserForm(Form): | ||
next = HiddenField() | ||
role_id = RadioField(u"Role", [AnyOf([str(val) for val in USER_ROLE.keys()])], | ||
choices=[(str(val), label) for val, label in USER_ROLE.items()]) | ||
status_id = RadioField(u"Status", [AnyOf([str(val) for val in USER_STATUS.keys()])], | ||
choices=[(str(val), label) for val, label in USER_STATUS.items()]) | ||
# A demo of datepicker. | ||
created_time = DateField(u'Created time') | ||
submit = SubmitField(u'Save') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from flask import Blueprint, render_template, request, flash | ||
from flask.ext.login import login_required | ||
|
||
from ..extensions import db | ||
from ..decorators import admin_required | ||
|
||
from ..user import User | ||
from .forms import UserForm | ||
|
||
|
||
admin = Blueprint('admin', __name__, url_prefix='/admin') | ||
|
||
|
||
@admin.route('/') | ||
@login_required | ||
@admin_required | ||
def index(): | ||
users = User.query.all() | ||
return render_template('admin/index.html', users=users, active='index') | ||
|
||
|
||
@admin.route('/users') | ||
@login_required | ||
@admin_required | ||
def users(): | ||
users = User.query.all() | ||
return render_template('admin/users.html', users=users, active='users') | ||
|
||
|
||
@admin.route('/user/<user_id>', methods=['GET', 'POST']) | ||
@login_required | ||
@admin_required | ||
def user(user_id): | ||
user = User.query.filter_by(id=user_id).first_or_404() | ||
form = UserForm(obj=user, next=request.args.get('next')) | ||
|
||
if form.validate_on_submit(): | ||
form.populate_obj(user) | ||
|
||
db.session.add(user) | ||
db.session.commit() | ||
|
||
flash('User updated.', 'success') | ||
|
||
return render_template('admin/user.html', user=user, form=form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.