Skip to content

Commit

Permalink
new session delete feature
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 13, 2016
1 parent 03defc1 commit 5bcb0cd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/appier_extras/parts/admin/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def routes(self):
(("GET",), "/admin/configs", self.list_configs),
(("GET",), "/admin/libraries", self.list_libraries),
(("GET",), "/admin/sessions", self.list_sessions),
(("GET",), "/admin/sessions/empty", self.empty_sessions),
(("GET",), "/admin/sessions/<str:sid>", self.show_session),
(("GET",), "/admin/sessions/<str:sid>/delete", self.delete_session),
(("GET",), "/admin/database", self.database),
(("GET",), "/admin/database/export", self.database_export),
(("GET",), "/admin/database/import", self.database_import),
Expand Down Expand Up @@ -382,14 +384,36 @@ def list_sessions(self):
sessions = self.request.session_c.all()
)

@appier.ensure(token = "admin")
def empty_sessions(self):
self.request.session_c.empty()
return self.redirect(
self.url_for(
"admin.list_sessions",
message = "Sessions emptied with success"
)
)

@appier.ensure(token = "admin")
def show_session(self, sid):
sid = str(sid)
return self.template(
"session.html.tpl",
section = "status",
session_s = self.request.session_c.get_s(sid)
)

@appier.ensure(token = "admin")
def delete_session(self, sid):
sid = str(sid)
self.request.session_c.expire(sid)
return self.redirect(
self.url_for(
"admin.list_sessions",
message = "Session deleted with success"
)
)

@appier.ensure(token = "admin")
def database(self):
return self.template(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
{% block title %}{{ session_s.sid }}{% endblock %}
{% block name %}{{ session_s.sid }}{% endblock %}
{% block style %}no-padding{% endblock %}
{% block buttons %}
{{ super() }}
<div class="button button-color button-red button-confirm"
data-message="Do you really want to delete [[{{ session_s.sid }}]] ?"
data-link="{{ url_for('admin.delete_session', sid = session_s.sid) }}">Delete</div>
{% endblock %}
{% block content %}
<table class="filter" data-no_input="1">
<thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
{% block title %}Sessions{% endblock %}
{% block name %}Sessions{% endblock %}
{% block style %}no-padding{% endblock %}
{% block buttons %}
{{ super() }}
<div class="button button-color button-red button-confirm"
data-message="Do you really want to [[clear all sessions]] ?"
data-link="{{ url_for('admin.empty_sessions') }}">Empty</div>
{% endblock %}
{% block content %}
<table class="filter no-fixed" data-no_input="1">
<thead>
Expand Down

0 comments on commit 5bcb0cd

Please sign in to comment.