Skip to content

Commit

Permalink
convert templates to jinja2
Browse files Browse the repository at this point in the history
  • Loading branch information
sl1-1 committed Feb 23, 2020
1 parent ee04638 commit 5c9fba3
Show file tree
Hide file tree
Showing 148 changed files with 3,738 additions and 3,067 deletions.
12 changes: 8 additions & 4 deletions weasyl/templates/admincontrol/acctverifylink.jinja2
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
$def with (token)
$:{RENDER("common/stage_title.html", ["Get Confirmation Link", "Administrator Control Panel", "/admincontrol"])}

{% extends 'common/base.jinja2' %}
{% from 'common/stage_title.jinja2' import stage %}
{% block content %}
{{ stage("Get Confirmation Link", "Administrator Control Panel", "/admincontrol") }}
<div id="error_content" class="content">
<p><a href="/verify/account?token=${token}">https://www.weasyl.com/verify/account?token=${token}</a></p>
{% if message %}<p>{{ message }}</p>{% else %}
<p><a href="/verify/account?token={{ token }}">https://www.weasyl.com/verify/account?token={{ token }}</a></p>

<div id="error_buttons">
<a href="javascript:void(0);" onclick="window.history.back();" class="button">Go Back</a>
<a href="/index" class="button">Return to the Home Page</a>
</div>
{% endif %}
</div>
{% endblock %}
9 changes: 6 additions & 3 deletions weasyl/templates/admincontrol/admincontrol.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$:{TITLE("Administrator Control Panel")}

{% extends 'common/base.jinja2' %}
{% from 'common/stage_title.jinja2' import stage %}
{% block content %}
{{ stage("Administrator Control Panel") }}
<div id="admincontrol_content" class="content" style="padding-top:2em;">
<div class="form skinny">
<div style="font-size:1.3em;">
Expand Down Expand Up @@ -28,7 +30,7 @@ $:{TITLE("Administrator Control Panel")}

<label>Get Confirmation Link</label>
<form class="form clear" action="/admincontrol/acctverifylink" method="post">
$:{CSRF()}
<input type="hidden" name="token" value="{{ TOKEN() }}" />
<p>Username</p>
<input type="text" name="username" class="input last-input" />
<p>Email</p>
Expand All @@ -39,3 +41,4 @@ $:{TITLE("Administrator Control Panel")}
<br />
</div>
</div>
{% endblock %}
93 changes: 51 additions & 42 deletions weasyl/templates/admincontrol/finduser.jinja2
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
$def with (query = None, form = None, row_offset=0)
$:{RENDER("common/stage_title.html", ["Search Users", "Administrator Control Panel", "/admincontrol"])}

{% extends 'common/base.jinja2' %}
{% from 'common/stage_title.jinja2' import stage %}
{% block content %}
{{ stage("Search Users", "Administrator Control Panel", "/admincontrol") }}
<div class="content">
$if(query == None):
{% if not query %}
<div class="form skinny clear">
<h3>Search Criteria</h3>

<form name="admincontrolfinduser" action="/admincontrol/finduser" method="post" class="clear">
$:{CSRF()}
<input type="hidden" name="token" value="{{ TOKEN() }}"/>

<label for="adminsearchid">UserID:</label>
<input type="text" class="input" name="userid" id="adminsearchid" />
Expand Down Expand Up @@ -53,14 +54,15 @@ $:{RENDER("common/stage_title.html", ["Search Users", "Administrator Control Pan
<button type="submit" class="button positive" style="float: right;">Search</button>
</form>
</div>
$elif(query):
{% elif(query) %}
<div>
$if query.rowcount == 1:
<h3>Search Results - ${query.rowcount} Account Found</h3>
$elif query.rowcount == 250:
{% if query.rowcount == 1 %}
<h3>Search Results - {{ query.rowcount }} Account Found</h3>
{% elif query.rowcount == 250 %}
<h3>Search Results - Many Accounts Found (250+)</h3>
$else:
<h3>Search Results - ${query.rowcount} Accounts Found</h3>
{% else %}
<h3>Search Results - {{ query.rowcount }} Accounts Found</h3>
{% endif %}

<table>
<tr>
Expand All @@ -72,50 +74,57 @@ $:{RENDER("common/stage_title.html", ["Search Users", "Administrator Control Pan
<td style="font-weight:700;">Manage User</td>
</tr>

$for i in query:
{% for i in query %}
<tr>
<td>${i.userid}</td>
$if i.is_banned:
<td><a href="/~${i.login_name}">${i.login_name}</a> <b>(Banned)</b></td>
$elif i.is_suspended:
<td><a href="/~${i.login_name}">${i.login_name}</a> <b>(Suspended)</b></td>
$else:
<td><a href="/~${i.login_name}">${i.login_name}</a></td>
<td>${i.email}</td>
$if i.ip_address_session:
<td>${i.ip_address_session}</td>
$elif i.ip_address_at_signup:
<td>${i.ip_address_at_signup}</td>
$else:
<td>{{ i.userid }}</td>
{% if i.is_banned %}
<td><a href="/~{{ i.login_name }}">{{ i.login_name }}</a> <b>(Banned)</b></td>
{% elif i.is_suspended: %}
<td><a href="/~{{ i.login_name }}">{{ i.login_name }}</a> <b>(Suspended)</b></td>
{% else %}
<td><a href="/~{{ i.login_name }}">{{ i.login_name }}</a></td>
{% endif %}
<td>{{ i.email }}</td>
{% if i.ip_address_session %}
<td>{{ i.ip_address_session }}</td>
{% elif i.ip_address_at_signup %}
<td>{{ i.ip_address_at_signup }}</td>
{% else %}
<td>No IP on file</td>
<td><a href="/staffnotes/${i.login_name}">${i.staff_notes} of &apos;em</a></td>
<td><a href="/admincontrol/manageuser?name=${i.login_name}">Manage User</a></td>
{% endif %}
<td><a href="/staffnotes/{{ i.login_name }}">{{ i.staff_notes }} of &apos;em</a></td>
<td><a href="/admincontrol/manageuser?name={{ i.login_name }}">Manage User</a></td>
</tr>
{% endfor %}
</table>
<form action="/admincontrol/finduser" method="post">
$:{CSRF()}
<input type="hidden" name="userid" value="${form.userid if form.userid != 0 else None}" />
<input type="hidden" name="username" value="${form.username}" />
<input type="hidden" name="email" value="${form.email}" />
<input type="hidden" name="excludebanned" ${'value=on' if form.excludebanned == "on" else ''} />
<input type="hidden" name="excludesuspended" ${'value=on' if form.excludesuspended == "on" else ''} />
<input type="hidden" name="excludeactive" ${'value=on' if form.excludeactive == "on" else ''} />
<input type="hidden" name="dateafter" value="${form.dateafter}" />
<input type="hidden" name="datebefore" value="${form.datebefore}" />
<input type="hidden" name="ipaddr" value="${form.ipaddr}" />
<input type="hidden" name="token" value="{{ TOKEN() }}" />
<input type="hidden" name="userid" value="{{ form.userid if form.userid != 0 else None }}" />
<input type="hidden" name="username" value="{{ form.username }}" />
<input type="hidden" name="email" value="{{ form.email }}" />
<input type="hidden" name="excludebanned" {{'value=on'|safe if form.excludebanned == "on" else ''}} />
<input type="hidden" name="excludesuspended" {{'value=on'|safe if form.excludesuspended == "on" else ''}} />
<input type="hidden" name="excludeactive" {{'value=on'|safe if form.excludeactive == "on" else ''}} />
<input type="hidden" name="dateafter" value="{{ form.dateafter }}" />
<input type="hidden" name="datebefore" value="{{ form.datebefore }}" />
<input type="hidden" name="ipaddr" value="{{ form.ipaddr }}" />
<div class="clear">
$if row_offset > 0:
<button class="button" name="row_offset" value=${row_offset - 250}>Previous 250</button>
$if query.rowcount == 250:
<button class="button" name="row_offset" value=${row_offset + 250}>Next 250</button>
{% if row_offset > 0 %}
<button class="button" name="row_offset" value={{ row_offset - 250 }}>Previous 250</button>
{% endif %}
{% if query.rowcount == 250 %}
<button class="button" name="row_offset" value={{ row_offset + 250 }}>Next 250</button>
{% endif %}
<a class="button positive" href="/admincontrol/finduser" style="float: right;">New search</a>
</div>
</form>
</div>
$else:
{% else %}
<div>
<h3>No search criteria were specified</h3>
Whoops! Looks like you didn't specify any search criteria. Head on back to <a href="/admincontrol/finduser">
re-enter your search parameters.</a>
</div>
{% endif %}
</div>
{% endblock %}
80 changes: 45 additions & 35 deletions weasyl/templates/admincontrol/manageuser.jinja2
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
$def with (profile)
$:{TITLE("User Management", "Administrator Control Panel", "/admincontrol")}

{% extends 'common/base.jinja2' %}
{% from 'common/stage_title.jinja2' import stage %}
{% block content %}
{{ stage("User Management", "Administrator Control Panel", "/admincontrol") }}
<div class="content">

<form name="admincontrolmanageuser" class="form constrained clear" action="/admincontrol/manageuser" method="post">
$:{CSRF()}
<input type="hidden" name="userid" value="${profile['userid']}" />
<input type="hidden" name="token" value="{{ TOKEN() }}"/>
<input type="hidden" name="userid" value="{{ profile['userid'] }}"/>

<span class="label">UserID</span>
<p>${profile['userid']}</p>
<p>{{ profile['userid'] }}</p>
<span class="label">Email</span>
<p>${profile['email']}</p>
<p>{{ profile['email'] }}</p>
<span class="label">Registration Date</span>
<p>${DATE(profile['unixtime'])} ${TIME(profile['unixtime'])}</p>
<p>{{ profile['unixtime'] | DATE }} {{ profile['unixtime'] | TIME }}</p>
<span class="label">IP Address at Registration</span>
$if profile['ip_address_at_signup']:
<p>${profile['ip_address_at_signup']}</p>
$else:
{% if profile['ip_address_at_signup'] %}
<p>{{ profile['ip_address_at_signup'] }}</p>
{% else %}
<p>Address was not recorded.</p>
{% endif %}
<span class="label">Staff Notes</span>
<p><a href="/staffnotes/${LOGIN(profile['username'])}">${profile['staff_notes']} of ’em</a></p>
<p><a href="/staffnotes/{{ profile['username'] | LOGIN }}">{{ profile['staff_notes'] }} of ’em</a></p>

<span class="label">Recent Login Sessions (<a href="#permissions">skip to Permissions</a>)</span>
$if profile['user_sessions']:
{% if profile['user_sessions'] %}
<table>
<tr>
<td style="font-weight:700;">Time Created</td>
<td style="font-weight:700;">Via Address</td>
<td style="font-weight:700;">User Agent</td>
</tr>
$for sess in profile['user_sessions']:
{% for sess in profile['user_sessions'] %}
<tr>
<td>${arrow.get(sess.created_at).format('YYYY-MM-DD HH:mm:ss')} (PDT)</td>
$if sess.ip_address:
<td>${sess.ip_address}</td>
$else:
<td>{{ arrow.get(sess.created_at).format('YYYY-MM-DD HH:mm:ss') }} (PDT)</td>
{% if sess.ip_address %}
<td>{{ sess.ip_address }}</td>
{% else %}
<td>No IP address recorded for this login session.</td>
$if sess.user_agent:
<td>${sess.user_agent}</td>
$else:
{% endif %}
{% if sess.user_agent %}
<td>{{ sess.user_agent }}</td>
{% else %}
<td>No user agent recorded for this login session.</td>
{% endif %}
</tr>
{% endfor %}
</table>
$else:
{% else %}
<p>No active login sessions for this user.</p>
{% endif %}

<fieldset>
<a id="permissions"></a>
<legend class="label">Permissions</legend>

<label class="input-checkbox option-with-label">
<input type="checkbox" name="permission-tag"$:{' checked' if 'g' not in profile['config'] else ''} /><span class="option-label">
<input type="checkbox" name="permission-tag"{{ ' checked' if 'g' not in profile['config'] }} /><span class="option-label">
Community tagging
<div class="option-label-description">Allow this user to add tags to others’ submissions.</div>
</span>
Expand All @@ -59,37 +65,41 @@ $:{TITLE("User Management", "Administrator Control Panel", "/admincontrol")}

<span class="label">Username</span>
<p><input type="checkbox" name="ch_username" />Update value</p>
<input type="text" class="input" name="username" value="${profile['username']}" />
<input type="text" class="input" name="username" value="{{ profile['username'] }}" />

<span class="label">Full Name</span>
<p><input type="checkbox" name="ch_full_name" />Update value</p>
<input type="text" class="input" name="full_name" value="${profile['full_name']}" />
<input type="text" class="input" name="full_name" value="{{ profile['full_name'] }}" />

<span class="label">Catchphrase</span>
<p><input type="checkbox" name="ch_catchphrase" />Update value</p>
<input type="text" class="input" name="catchphrase" value="${profile['catchphrase']}" />
<input type="text" class="input" name="catchphrase" value="{{ profile['catchphrase'] }}" />

<span class="label">Date of Birth</span>
<p><input type="checkbox" name="ch_birthday" />Update value</p>
<input type="date" class="input" name="birthday" value="${ISO8601_DATE(profile['birthday'])}" />
<input type="date" class="input" name="birthday" value="{{ profile['birthday'] | ISO8601_DATE }}" />

<span class="label">Gender</span>
<p><input type="checkbox" name="ch_gender" />Update value</p>
<input type="text" class="input" name="gender" value="${profile['gender']}" />
<input type="text" class="input" name="gender" value="{{ profile['gender'] }}" />

<span class="label">Location</span>
<p><input type="checkbox" name="ch_country" />Update value</p>
<input type="text" class="input last-input" name="country" value="${profile['country']}" />
<input type="text" class="input last-input" name="country" value="{{ profile['country'] }}"/>

$if profile['sorted_user_links']:
{% if profile['sorted_user_links'] %}
<h3>Social links</h3>
$for site, values in profile['sorted_user_links']:
$for value in values:
<span class="label">${site} (${value})</span>
<p><input type="checkbox" name="remove_social" value="${site}">Remove</p>
{% for site, values in profile['sorted_user_links'] %}
{% for value in values %}
<span class="label">{{ site }} ({{ value }})</span>
<p><input type="checkbox" name="remove_social" value="{{ site }}">Remove</p>
{% endfor %}
{% endfor %}
{% endif %}

<button type="submit" class="button highlighted" style="float: right;">Save Changes</button>
<a class="button" href="/admincontrol">Go Back</a>
<a class="button" href="/~${LOGIN(profile['username'])}">Profile</a>
<a class="button" href="/~{{ profile['username'] | LOGIN }}">Profile</a>
</form>
</div>
{% endblock %}
40 changes: 23 additions & 17 deletions weasyl/templates/admincontrol/pending_accounts.jinja2
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
$def with (query)
$:{RENDER("common/stage_title.html", ["Accounts Pending Creation", "Administrator Control Panel", "/admincontrol"])}

{% extends 'common/base.jinja2' %}
{% from 'common/stage_title.jinja2' import stage %}
{% block content %}
{{ stage("Accounts Pending Creation", "Administrator Control Panel", "/admincontrol") }}
<div class="content">
$if query:
{% if query %}
<div>
<h3>Accounts Pending Creation</h3>
<form action="/admincontrol/pending_accounts" method="POST">
$:{CSRF()}
<input type="hidden" name="token" value="{{ TOKEN() }}"/>
<table>
<tr>
<td width="10%" style="font-weight:700;">Purge?</td>
Expand All @@ -15,26 +16,31 @@ $:{RENDER("common/stage_title.html", ["Accounts Pending Creation", "Administrato
<td style="font-weight:700;">Creation Date</td>
</tr>

$for i in query:
$ date = arrow.get(i.unixtime)
{% for i in query %}
{% set date = arrow.get(i.unixtime) %}
<tr>
<td style="padding-bottom:1em;"><button class="button negative" name="logincreatetoken" value="${i.token}">Purge</button></td>
<td style="padding-bottom:1em;">${i.username}</td>
$if i.invalid:
$if i.invalid_email_addr:
<td style="padding-bottom:1em;"><em>Invalid <code>logincreate</code> record -- Email in use:</em> ${i.invalid_email_addr}</td>
$else:
<td style="padding-bottom:1em;"><button class="button negative" name="logincreatetoken" value="{{ i.token }}">Purge</button></td>
<td style="padding-bottom:1em;">{{ i.username }}</td>
{% if i.invalid %}
{% if i.invalid_email_addr %}
<td style="padding-bottom:1em;"><em>Invalid <code>logincreate</code> record -- Email in use:</em> {{ i.invalid_email_addr }}</td>
{% else %}
<td style="padding-bottom:1em;"><em>Invalid <code>logincreate</code> record -- Email in use, but not recorded</em></td>
$else:
<td style="padding-bottom:1em;">${i.email}</td>
<td style="padding-bottom:1em;">${date.isoformat()}</td>
{% endif %}
{% else %}
<td style="padding-bottom:1em;">{{ i.email }}</td>
{% endif %}
<td style="padding-bottom:1em;">{{ date.isoformat() }}</td>
</tr>
{% endfor %}
</table>
</form>
</div>
$else:
{% else %}
<div>
<h3>Accounts Pending Creation</h3>
There are no pending accounts to display.
</div>
{% endif %}
</div>
{% endblock %}
Loading

0 comments on commit 5c9fba3

Please sign in to comment.