-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c548b6d
commit 5c303cd
Showing
9 changed files
with
91 additions
and
16 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
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 |
---|---|---|
@@ -1,19 +1,56 @@ | ||
from flask_admin import Admin | ||
from flask_admin import Admin, AdminIndexView, BaseView, expose | ||
from flask_basicauth import BasicAuth | ||
from flask_admin.contrib.sqla import ModelView | ||
from database.db import db | ||
from database.models.access import Access | ||
from database.models.authors import Author | ||
from database.models.sessions import Session | ||
from database.models.slugs import Slug | ||
|
||
admin = Admin() | ||
|
||
class PkModelView(ModelView): | ||
column_display_pk = True | ||
class AuthenticatedAdminView(AdminIndexView): | ||
|
||
def is_accessible(self): | ||
if not auth.authenticate(): | ||
return False | ||
else: | ||
return True | ||
|
||
def inaccessible_callback(self, name, **kwargs): | ||
return auth.challenge() | ||
|
||
super(AdminIndexView) | ||
|
||
|
||
class AuthenticatedModelView(ModelView): | ||
def is_accessible(self): | ||
if not auth.authenticate(): | ||
return False | ||
else: | ||
return True | ||
|
||
def inaccessible_callback(self, name, **kwargs): | ||
return auth.challenge() | ||
|
||
super(ModelView) | ||
|
||
admin.add_view(PkModelView(Access, db.session)) | ||
admin.add_view(PkModelView(Author, db.session)) | ||
admin.add_view(PkModelView(Session, db.session)) | ||
admin.add_view(PkModelView(Slug, db.session)) | ||
class HomeView(BaseView): | ||
@expose('/') | ||
def index(self): | ||
arg1 = 'Hello' | ||
return self.render('admin/myhome.html', arg1=arg1) | ||
|
||
|
||
class PkModelView(AuthenticatedModelView): | ||
column_display_pk = True | ||
|
||
super(AuthenticatedModelView) | ||
|
||
|
||
admin = Admin(index_view=AuthenticatedAdminView(), template_mode='bootstrap4') | ||
auth = BasicAuth() | ||
|
||
admin.add_view(PkModelView(Access, db.session, name='Access', category='Database')) | ||
admin.add_view(PkModelView(Author, db.session, name='Authors', category='Database')) | ||
admin.add_view(PkModelView(Session, db.session, name='Sessions', category='Database')) | ||
admin.add_view(PkModelView(Slug, db.session, name='Posts', category='Database')) |
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
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,14 @@ | ||
{% extends 'admin/master.html' %} | ||
|
||
{% block body %} | ||
{{ super() }} | ||
<div style="margin: auto; text-align: center;"> | ||
<img src="{{ url_for('static', filename='logo.png') }}" style="max-width: 200px;"/> | ||
<h2>Ghost IOTA Pay</h2> | ||
<h3>Admin Panel</h3> | ||
<p>Pay per content gateway for <a href="https://ghost.org/">Ghost Blogs</a></p> | ||
<div style="margin-top: 50px;"> | ||
<p><a href="https://github.com/F-Node-Karlsruhe/ghost-iota-pay"><img width="16" src="{{ url_for('static', filename='github.png') }}"/></a></p> | ||
</div> | ||
</div> | ||
{% endblock body %} |