aded table, pagination, edit, view pages, ad tested it with person roles. errors like 404 don't work correctly yet
parent
86b4f16a8e
commit
1d3fd5086f
Binary file not shown.
@ -0,0 +1,7 @@
|
|||||||
|
from minibase.app import db, create_app, bcrypt
|
||||||
|
from minibase.blueprints.user.models import Users, User_Roles
|
||||||
|
from minibase.blueprints.geography.models import Countries
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
|
app.app_context().push()
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@
|
|||||||
|
from minibase.app import db
|
||||||
|
|
||||||
|
|
||||||
|
class table_printable:
|
||||||
|
def __init__(self, table, link_for_item, item_to_be_linked):
|
||||||
|
self.titles = table.__table__.columns.keys()
|
||||||
|
self.lines = table.query.all()
|
||||||
|
self.link_for_item = link_for_item
|
||||||
|
self.item_to_be_linked = item_to_be_linked
|
||||||
|
self.paginate = 0
|
||||||
|
|
||||||
|
# https://www.youtube.com/watch?v=PSWf2TjTGNY&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH&index=9
|
||||||
|
class table_printable_paginate:
|
||||||
|
def __init__(self, table, current_page, per_page, link_for_item, item_to_be_linked):
|
||||||
|
self.titles = table.__table__.columns.keys()
|
||||||
|
self.lines = table.query.paginate(page=current_page, per_page=per_page)
|
||||||
|
self.link_for_item = link_for_item
|
||||||
|
self.item_to_be_linked = item_to_be_linked
|
||||||
|
self.paginate = 1
|
||||||
|
|
||||||
|
|
||||||
|
def dbAdd(dbClass):
|
||||||
|
db.session.add(dbClass)
|
||||||
|
|
||||||
|
|
||||||
|
def dbCommit():
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
def dbAddAndCommit(dbClass):
|
||||||
|
db.session.add(dbClass)
|
||||||
|
db.session.commit()
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@
|
|||||||
|
from flask import Blueprint, render_template
|
||||||
|
import minibase.theme as theme
|
||||||
|
|
||||||
|
errors = Blueprint('errors', __name__, template_folder='templates')
|
||||||
|
|
||||||
|
@errors.app_errorhandler(403)
|
||||||
|
def error_403(error):
|
||||||
|
return render_template('errors/403.html', theme=theme), 403
|
@ -0,0 +1,9 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="content-section">
|
||||||
|
<h1>Your dont have permission to do that (403)</h1>
|
||||||
|
<p>PLease Check your account and try again</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock content %}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 550 KiB |
@ -0,0 +1,22 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="container-fluid text-center rounded-3 mt-2 mb-2" style="{{ theme.form.div_style }};">
|
||||||
|
<h1 class="account-heading" style="color: {{ theme.orange }};">{{ title }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="container-fluid rounded-3 " style="{{ theme.form.div_style }};">
|
||||||
|
{% include 'form.html' %}
|
||||||
|
{% if extraButtons %}
|
||||||
|
</div>
|
||||||
|
<div class="container-fluid rounded-3 mt-2 mb-2" style="{{ theme.form.div_style }};">
|
||||||
|
<div class="btn-group">
|
||||||
|
<br>
|
||||||
|
{% for button in extraButtons %}
|
||||||
|
<li><a href ="{{ button.link }}" class="{{ theme.form.submit_class }}" style="{{ theme.form.submit_style }}">{{ button.name }}<a>
|
||||||
|
{% endfor %}
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock content %}
|
@ -0,0 +1,14 @@
|
|||||||
|
<ul class="pagination">
|
||||||
|
{# https://www.youtube.com/watch?v=PSWf2TjTGNY&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH&index=9 #}
|
||||||
|
{% for page_num in table.lines.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2) %}
|
||||||
|
{% if page_num %}
|
||||||
|
{% if table.lines.page == page_num %}
|
||||||
|
<li class="page-item"><a class="btn btn-info mt-1" href="{{ url_for( request.endpoint , page=page_num) }}">{{ page_num }}</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item"><a class="btn btn-outline-info mt-1" href="{{ url_for( request.endpoint , page=page_num) }}">{{ page_num }}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<h4 class="account-heading " style="color: {{ theme.orange }};">...</h4>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
@ -1,25 +1,59 @@
|
|||||||
<div class="table-responsive">
|
<div class="table-responsive rounded " style="background-color: {{ theme.black }};">
|
||||||
<table class="table table-dark table-striped-columns table-hover">
|
<table id="data" class="table table-dark table-striped-columns table-hover mt-3 mb-3 mr-3 ml-3">
|
||||||
<thead>
|
<thead>
|
||||||
{{ info }}
|
{{ info }}
|
||||||
<tr>
|
<tr>
|
||||||
{% for title in titles %}
|
{% for title in table.titles %}
|
||||||
<th scope="col">{{ title }}</th>
|
<th scope="col">{{ title }}</th>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
{% for item in table %}
|
{% if table.paginate == 1 %}
|
||||||
|
{% for line in table.lines.items %}
|
||||||
<tr>
|
<tr>
|
||||||
{% for title in titles %}
|
{% for title in table.titles %}
|
||||||
{% if title == 'id' %}
|
{% if title == table.item_to_be_linked %}
|
||||||
<th scope="col"><a href="{{ item_link }}{{ item|attr(title) }}">{{ item|attr(title) }}</a></th>
|
<th scope="col" style="white-space: nowrap;"><a href="{{ table.link_for_item }}{{ line|attr(title) }}">{{ line|attr(title) }}</a></th>
|
||||||
{% else %}
|
{% else %}
|
||||||
<th scope="col">{{ item|attr(title) }}</th>
|
<th scope="col" style="white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">{{ line|attr(title) }}</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for line in table.lines %}
|
||||||
|
<tr>
|
||||||
|
{% for title in table.titles %}
|
||||||
|
{% if title == table.item_to_be_linked %}
|
||||||
|
<th scope="col"><a href="{{ table.link_for_item }}{{ line|attr(title) }}">{{ line|attr(title) }}</a></th>
|
||||||
|
{% else %}
|
||||||
|
<th scope="col">{{ line|attr(title) }}</th>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% if table.paginate == 1 %}
|
||||||
|
{% if table.lines.pages < 2 %}
|
||||||
|
{% else %}
|
||||||
|
{% include 'pagination.html' %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% block scripts %}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#data').DataTable({
|
||||||
|
columns: [
|
||||||
|
null,
|
||||||
|
{searchable: false},
|
||||||
|
{orderable: false, searchable: false},
|
||||||
|
{orderable: false, searchable: false},
|
||||||
|
null],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="container-fluid text-center rounded-3 mt-2 mb-2" style="{{ theme.form.div_style }};">
|
||||||
|
<h1 class="account-heading" style="color: {{ theme.orange }};">{{ title }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="container-fluid rounded-3 mt-2 mb-2" style="{{ theme.form.div_style }};">
|
||||||
|
{% include 'table.html' %}
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
Loading…
Reference in new issue