Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
redeleitsystem
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Security & Compliance
Security & Compliance
Dependency List
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
redl
redeleitsystem
Commits
a4d0d865
Commit
a4d0d865
authored
Nov 07, 2015
by
Robin Sonnabend
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Admin overview
parent
bca7b24c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
13 deletions
+84
-13
models/forms.py
models/forms.py
+1
-1
modules/admin.py
modules/admin.py
+19
-5
templates/admin_event_index.html
templates/admin_event_index.html
+7
-1
templates/admin_event_show.html
templates/admin_event_show.html
+41
-0
templates/admin_index.html
templates/admin_index.html
+16
-6
No files found.
models/forms.py
View file @
a4d0d865
...
...
@@ -32,4 +32,4 @@ class NewEventForm(Form):
class
NewTopicForm
(
Form
):
name
=
StringField
(
"Name"
,
validators
=
[
InputRequired
(
"Entering the name is required."
)])
mode
=
StringField
(
"Mode"
,
validators
=
[
InputRequired
(
"Entering the mode is required."
),
AnyOf
(
values
=
[
"balanced"
,
"fifo"
],
message
=
"Must be 'balanced' or 'fifo' atm."
)])
event_id
=
HiddenField
(
"Event_
ID
"
)
event_id
=
HiddenField
(
"Event_
id
"
)
modules/admin.py
View file @
a4d0d865
...
...
@@ -15,8 +15,8 @@ admin = Blueprint("admin", __name__)
@
admin_permission
.
require
()
def
index
():
users
=
User
.
query
.
limit
(
10
)
.
all
()
topics
=
Topic
.
query
.
limit
(
10
)
.
all
()
return
render_layout
(
"admin_index.html"
,
users
=
users
,
topics
=
topic
s
)
events
=
Event
.
query
.
limit
(
10
)
.
all
()
return
render_layout
(
"admin_index.html"
,
users
=
users
,
events
=
event
s
)
@
admin
.
route
(
"/user/"
)
@
login_required
...
...
@@ -74,6 +74,16 @@ def user_new():
def
event
():
events
=
Event
.
query
.
all
()
return
render_layout
(
"admin_event_index.html"
,
events
=
events
)
@
admin
.
route
(
"/even/show"
)
@
login_required
@
admin_permission
.
require
()
def
event_show
():
event_id
=
request
.
args
.
get
(
"id"
,
None
)
if
event_id
is
not
None
:
event
=
Event
.
query
.
filter_by
(
id
=
event_id
)
.
first
()
return
render_layout
(
"admin_event_show.html"
,
event
=
event
)
@
admin
.
route
(
"/event/new"
,
methods
=
[
"GET"
,
"POST"
])
...
...
@@ -98,7 +108,7 @@ def event_new():
def
event_delete
():
event_id
=
request
.
args
.
get
(
"id"
,
None
)
if
event_id
is
not
None
:
event
=
Event
.
query
.
filter_by
(
id
=
event_id
)
.
first
()
event
=
Event
.
query
.
filter_by
(
id
=
event_id
)
.
first
()
db
.
session
.
delete
(
event
)
db
.
session
.
commit
()
flash
(
"Event deleted."
,
"alert-success"
)
...
...
@@ -111,9 +121,9 @@ def event_edit():
event_id
=
request
.
args
.
get
(
"id"
,
None
)
if
event_id
is
not
None
:
event
=
db
.
session
.
query
(
Event
)
.
filter_by
(
id
=
event_id
)
.
first
()
form
=
NewEventForm
(
obj
=
topic
)
form
=
NewEventForm
(
obj
=
event
)
if
form
.
validate_on_submit
():
form
.
populate_obj
(
topic
)
form
.
populate_obj
(
event
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
".index"
))
else
:
...
...
@@ -135,6 +145,10 @@ def topic_new():
db
.
session
.
add
(
topic
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
".topic"
))
event_id
=
request
.
args
.
get
(
"event_id"
,
None
)
if
event_id
is
None
:
return
redirect
(
url_for
(
".index"
))
form
.
event_id
.
data
=
event_id
return
render_layout
(
"admin_topic_new.html"
,
form
=
form
)
@
admin
.
route
(
"/topic/delete"
)
...
...
templates/admin_event_index.html
View file @
a4d0d865
...
...
@@ -7,13 +7,19 @@
<thead>
<tr>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Name
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Edit
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Delete
</th>
</tr>
</thead>
<tbody>
{% for event in events %}
<tr>
<td
class=
"mdl-data-table__cell--non-numeric"
><a
href=
"{{ url_for("
.
event_edit
",
id=
event.id)
}}"
>
{{ event.name }}
</a></td>
<td
class=
"mdl-data-table__cell--non-numeric"
><a
href=
"{{ url_for("
.
event_show
",
id=
event.id)
}}"
>
{{ event.name }}
</a></td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
<a
href=
"{{ url_for("
.
event_edit
",
id=
event.id)
}}"
>
<i
class=
"material-icons"
>
edit
</i>
</a>
</td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
<a
href=
"{{ url_for('.event_delete', id=event.id) }}"
>
<i
class=
"material-icons"
>
delete
</i>
...
...
templates/admin_event_show.html
0 → 100644
View file @
a4d0d865
{% extends "admin_index.html" %}
{% block admin_title %}Event - {{ event.name }}{% endblock %}
{% block content %}
<div
class=
"mdl-cell mdl-cell--3-col mdl-grid mdl-grid--no-spacing"
>
<table
class=
"mdl-data-table mdl-js-table mdl-shadow--2dp mdl-cell mdl-cell--3-col"
>
<thead>
<tr>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Name
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Mode
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Edit
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Delete
</th>
</tr>
</thead>
<tbody>
{% for topic in event.topics %}
<tr>
<td
class=
"mdl-data-table__cell--non-numeric"
><a
href=
"{{ url_for("
.
topic_show
",
id=
topic.id)
}}"
>
{{ topic.name }}
</a></td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
<a
href=
"{{ url_for("
.
topic_edit
",
id=
topic.id)
}}"
>
<i
class=
"material-icons"
>
edit
</i>
</a>
</td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
<a
href=
"{{ url_for('.topic_delete', id=topic.id) }}"
>
<i
class=
"material-icons"
>
delete
</i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"rede-separator"
>
<div
class=
"mdl-cell mdl-cell--1-col"
>
<a
class=
"mdl-button mdl-button--colored mdl-js-button mdl-button--fab mdl-js-ripple-effect"
href=
"{{ url_for('.topic_new', event_id=event.id) }}"
>
<i
class=
"material-icons"
>
add
</i>
</a>
</div>
</div>
</div>
{% endblock %}
templates/admin_index.html
View file @
a4d0d865
...
...
@@ -32,21 +32,31 @@
<thead>
<tr>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Name
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Mode
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Edit
</th>
<th
class=
"mdl-data-table__cell--non-numeric"
>
Delete
</th>
</tr>
</thead>
<tbody>
{% for
topic
in events %}
{% for
event
in events %}
<tr>
<td
class=
"mdl-data-table__cell--non-numeric"
><a
href=
"{{ url_for("
.
topic_edit
",
id=
event.id)
}}"
>
{{ event.name }}
</a></td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
{{ topic.mode }}
</td>
<td
class=
"mdl-data-table__cell--non-numeric"
><a
href=
"{{ url_for("
.
event_show
",
id=
event.id)
}}"
>
{{ event.name }}
</a></td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
<a
href=
"{{ url_for("
.
event_edit
",
id=
event.id)
}}"
>
<i
class=
"material-icons"
>
edit
</i>
</a>
</td>
<td
class=
"mdl-data-table__cell--non-numeric"
>
<a
href=
"{{ url_for("
.
event_delete
",
id=
event.id)
}}"
>
<i
class=
"material-icons"
>
delete
</i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"mdl-cell mdl-cell--3-col mdl-cell--3-col-tablet mdl-cell--2-col-phone"
>
<a
class=
"mdl-button mdl-button--colored mdl-js-button"
href=
"{{ url_for("
.
topic
")
}}"
>
All
topic
s
<a
class=
"mdl-button mdl-button--colored mdl-js-button"
href=
"{{ url_for("
.
event
")
}}"
>
All
event
s
</a>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment