-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1591 from rafalkowalski/dev
adding pages fixed
- Loading branch information
Showing
7 changed files
with
227 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""empty message | ||
Revision ID: 047f7c3db184 | ||
Revises: dd24d9e90809 | ||
Create Date: 2016-07-12 11:28:08.051094 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '047f7c3db184' | ||
down_revision = 'dd24d9e90809' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import sqlalchemy_utils | ||
from sqlalchemy.dialects import postgresql | ||
|
||
def upgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('pages', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(), nullable=False), | ||
sa.Column('title', sa.String(), nullable=True), | ||
sa.Column('url', sa.String(), nullable=False), | ||
sa.Column('description', sa.String(), nullable=True), | ||
sa.Column('place', sa.String(), nullable=True), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('pages') | ||
### end Alembic commands ### |
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,40 @@ | ||
"""Copyright 2016 Rafal Kowalski""" | ||
from . import db | ||
|
||
|
||
class Page(db.Model): | ||
"""Page model class""" | ||
__tablename__ = 'pages' | ||
id = db.Column(db.Integer, primary_key=True) | ||
name = db.Column(db.String, nullable=False) | ||
title = db.Column(db.String) | ||
url = db.Column(db.String, nullable=False) | ||
description = db.Column(db.String) | ||
place = db.Column(db.String) | ||
def __init__(self, name=None,title=None, description=None, url=None, place=None): | ||
self.name = name | ||
self.description = description | ||
self.title = title | ||
self.url = url | ||
self.place = place | ||
|
||
def __repr__(self): | ||
return '<Page %r>' % self.name | ||
|
||
def __str__(self): | ||
return unicode(self).encode('utf-8') | ||
|
||
def __unicode__(self): | ||
return self.name | ||
|
||
@property | ||
def serialize(self): | ||
"""Return object data in easily serializeable format""" | ||
return { | ||
'id': self.id, | ||
'name': self.name, | ||
'description': self.description, | ||
'title': self.title, | ||
'url': self.url, | ||
'place': self.place | ||
} |
52 changes: 52 additions & 0 deletions
52
open_event/templates/gentelella/admin/super_admin/pages/_create_page_modal.html
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,52 @@ | ||
<div class="modal fade" id="importModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | ||
<form class="admin-form form-horizontal" action="/admin/pages/create" method="POST"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span | ||
aria-hidden="true">×</span></button> | ||
<h4 class="modal-title" id="myModalLabel">Page Details</h4> | ||
</div> | ||
<div class="modal-body"> | ||
|
||
<div class="item form-group"> | ||
<label>NAME</label> | ||
<input type="text" class="form-control col-md-7 col-xs-12" name="name"/> | ||
</div> | ||
<div class="item form-group"> | ||
<label>TITLE</label> | ||
<input type="text" class="form-control col-md-7 col-xs-12" name="title"/> | ||
</div> | ||
<div class="item form-group"> | ||
<label>URL</label> | ||
<input type="text" class="form-control col-md-7 col-xs-12" name="url"/> | ||
</div> | ||
<div class="item form-group"> | ||
<label>DESCRIPTION</label> | ||
<textarea type="text" class="form-control col-md-7 col-xs-12" name="description"> </textarea> | ||
</div> | ||
<div class="item form-group"> | ||
<label>PLACE</label> | ||
<select type="text" class="form-control col-md-7 col-xs-12" name="place"> | ||
<option value="use_open_event">Use Open Event</option> | ||
<option value="footer_menu">Footer Menu</option> | ||
</select> | ||
</div> | ||
|
||
|
||
<br> | ||
<span id="import_status"></span> | ||
<span id="import_error" class="red"></span> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-primary" id="btnImportEvent" onclick="">Create Page</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<script> | ||
|
||
|
||
</script> |
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,8 +1,34 @@ | ||
from flask import redirect, request, url_for | ||
from flask_admin import expose | ||
from open_event.views.admin.super_admin.super_admin_base import SuperAdminBaseView | ||
|
||
from ....helpers.data_getter import DataGetter | ||
from ....helpers.data import DataManager, delete_from_db | ||
|
||
class SuperAdminPagesView(SuperAdminBaseView): | ||
@expose('/') | ||
def index_view(self): | ||
return self.render('/gentelella/admin/super_admin/pages/pages.html') | ||
pages = DataGetter.get_all_pages() | ||
return self.render('/gentelella/admin/super_admin/pages/pages.html', pages=pages) | ||
|
||
@expose('/create', methods=['POST']) | ||
def create_view(self): | ||
DataManager.create_page(request.form) | ||
return redirect(url_for('sadmin_pages.index_view')) | ||
|
||
@expose('/<page_id>', methods=['GET', 'POST']) | ||
def details_view(self, page_id): | ||
page = DataGetter.get_page_by_id(page_id) | ||
if request.method == 'POST': | ||
print request.form | ||
DataManager().update_page(page, request.form) | ||
return redirect(url_for('sadmin_pages.details_view', page_id=page_id )) | ||
pages = DataGetter.get_all_pages() | ||
return self.render('/gentelella/admin/super_admin/pages/pages.html', | ||
pages=pages, | ||
current_page=page) | ||
|
||
@expose('/<page_id>/trash', methods=['GET']) | ||
def trash_view(self, page_id): | ||
page = DataGetter.get_page_by_id(page_id) | ||
delete_from_db(page, "Page has already deleted") | ||
return redirect(url_for('sadmin_pages.index_view')) |