From 94a8f6a00efa21dc9f17ec9d181391526eab7a54 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 18 Nov 2014 05:04:58 +0100 Subject: admin: add simple flask-peewee admin interface --- admin.py | 13 +++++++++++++ admin/static | 1 + main.py | 1 + models.py | 12 ++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 admin.py create mode 120000 admin/static diff --git a/admin.py b/admin.py new file mode 100644 index 0000000..1344546 --- /dev/null +++ b/admin.py @@ -0,0 +1,13 @@ +from flask_peewee.admin import Admin +from app import app +from auth import auth +from models import User, Group, Member, Pad, Session + +admin = Admin(app, auth) +auth.register_admin(admin) +admin.register(User) +admin.register(Group) +admin.register(Member) +admin.register(Pad) +admin.register(Session) +admin.setup() diff --git a/admin/static b/admin/static new file mode 120000 index 0000000..72e6e47 --- /dev/null +++ b/admin/static @@ -0,0 +1 @@ +/home/pad/.virtualenvs/padlite-teams/lib/python2.7/site-packages/flask_peewee/static \ No newline at end of file diff --git a/main.py b/main.py index a57d80d..c521ad0 100755 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from app import app, db +from admin import admin from models import create_tables from views import * diff --git a/models.py b/models.py index fd33a47..0469802 100644 --- a/models.py +++ b/models.py @@ -12,6 +12,9 @@ class User(db.Model): active = BooleanField(default=True) admin = BooleanField(default=False) + def __str__(self): + return self.username + def __unicode__(self): return self.username @@ -21,6 +24,9 @@ class Group(db.Model): public = BooleanField(default=False) browsable = BooleanField(default=False) + def __str__(self): + return self.name + def __unicode__(self): return self.name @@ -43,6 +49,9 @@ class Member(db.Model): manager = BooleanField(default=False) admin = BooleanField(default=False) + def __str__(self): + return "%s member of %s" % (self.user.username, self.group.name) + def __unicode__(self): return "%s member of %s" % (self.user.username, self.group.name) @@ -92,6 +101,9 @@ class Pad(db.Model): public = BooleanField(default=False) password = CharField(null=True) + def __str__(self): + return self.name + def __unicode__(self): return self.name -- cgit v1.2.3-1-g7c22