-
Notifications
You must be signed in to change notification settings - Fork 16
/
view.html
152 lines (135 loc) · 6.65 KB
/
view.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{# ~~Account:Page~~ #}
{# Use dashboard layout for ManEds only #}
{# TODO: switch to dashboard layout once Ed + Associate Ed new workflow UI is done #}
{% if current_user.has_role("admin") %}
{% extends "layouts/dashboard_base.html" %}
{% elif current_user.has_role("publisher") %}
{% extends "publisher/publisher_base.html" %}
{% else %}
{% extends "editor/editor_base.html" %}
{% endif %}
{% block page_title %}{{ account.name if account.name else account.email }}’s profile{% endblock %}
{% block content %}
{# TODO remove this once other dashboards are done #}
{% if not current_user.has_role("admin") %}<main class="container page-content">{% endif %}
<div class="row">
<div class="col-md-8">
{% if current_user.has_role("list_users") or current_user.has_role("admin_journals") %}
<ul class="tags">
{% if current_user.has_role("list_users") %}
<li><a href="/account" class="tag tag--secondary">View <strong>all</strong> user accounts</a></li>
{% endif %}
{% if current_user.has_role("admin_journals") %}
{% set Q1 = '{"query":{"bool":{"must":[{"term":{"admin.owner.exact":"' %}
{% set Q2 = '"}}]}}}' %}
<li><a href="/admin/?source={{Q1}}{{account.id}}{{Q2}}" class="tag tag--secondary">View <strong>this user’s</strong> journals</a></li>
{% endif %}
</ul>
{% endif %}
{% if current_user.id == account.id or current_user.is_super %}
{% if current_user.id != account.id %}
<p class="alert">
<span data-feather="alert-triangle" aria-hidden="true"></span>
You are editing a user account that is <strong>not your own</strong>. Be careful!
</p>
{% endif %}
<h2>Edit your details</h2>
{% include 'account/_edit_user_form.html' %}
{% if current_user.is_super %}
<hr/>
<h2>Delete this account</h2>
<p><span data-feather="alert-triangle" aria-hidden="true"></span> This <strong>irrevocably</strong> deletes the account.</p>
<form action="" method="POST">
<input type="checkbox" name="delete_confirm" id="delete_confirm" value="delete_confirm">
<label for="delete_confirm">Yes, I’m sure</label>
<input type="submit" name="submit" value="Delete" class="button">
</form>
{% endif %}
{% else %}
<h2>{{ account.id }}</h2>
<p>You are not logged in as this user. Use the <a href="/account/login">login page</a> if you want to change this</p>
{% endif %}
</div>
<div class="col-md-4">
<aside>
<h2 class="label">Marketing consent</h2>
<form action="" method="POST" class="form form--compact">
<p>
Your DOAJ account must have an email address in it because we have to contact you with important account and journal information such as security updates; updates to the information we hold about your journal; problems with article metadata, etc. This is part of our responsibility to you to ensure that your journal information is safe and up-to-date.
</p>
<p>
We also send out occasional marketing emails, such as publisher surveys, opinion polls, newsletters and new functionality alerts. For those emails, we need your consent to use your email address. You may come back here and change your response at any time.
</p>
<div class="form__question">
<input type="radio" name="marketing_consent" id="marketing_consent_yes" {% if account.marketing_consent %}checked="checked"{% endif %} value="true">
<label for="marketing_consent_yes">
I consent to DOAJ using my email address for its own marketing purposes
</label>
<input type="radio" name="marketing_consent" id="marketing_consent_no" {% if account.marketing_consent == False %}checked="checked"{% endif %} value="false">
<label for="marketing_consent_no">I do not consent to DOAJ using my email address for its own marketing purposes</label>
</div>
<p>
DOAJ does not share your name and email address with any other organisation. Please read <a href="{{ url_for('doaj.privacy') }}">our full privacy policy</a>.
</p>
<input type="submit" class="button" name="submit" value="Save consent">
</form>
</aside>
<aside>
<h2 class="label">Your API access</h2>
<dl>
<dt>ID</dt>
<dd><code>{{ account.id }}</code></dd>
{% if account.has_role("api") %}
<dt>API Key</dt>
<dd>
<code id="user-api">{{ account.api_key }}</code>
<span class="form__click-to-copy" id="click-to-copy--api" data-feather="copy" aria-hidden="true"></span><span class="sr-only">Copy value</span>
<span class="tag tag--confirmation" style="display:none" id="copy-confirmation--api">Copied!</span>
</dd>
{% endif %}
</dl>
{% if account.has_role("api") %}
<form action="" method="POST" class="form form--compact">
<button type="submit" class="button" name="submit" value="Generate a new API Key">Generate a new API key</button>
</form>
{% endif %}
</aside>
</div>
</div>
{% if not current_user.has_role("admin") %}</main>{% endif %}
{% endblock %}
{% block extra_js_bottom %}
<script type="text/javascript" src="/static/js/dontleave.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Populate select2 role picker
$('#roles').select2({tags:["{{current_user.all_top_level_roles()|join('","')|safe}}"]})
// Scroll to errors
let firstError = $('.errors')[0];
if (firstError) {
$(window).scrollTop($(firstError).offset().top - 100)
}
{% if account.has_role("api") %}
// Copy API key to clipboard
$('#click-to-copy--api').click(function() {
let value_to_copy = $('#user-api').html();
navigator.clipboard.writeText(value_to_copy);
var confirmation = $("#copy-confirmation--api");
confirmation.text("Copied: " + value_to_copy);
confirmation.show().delay(3000).fadeOut();
});
{% endif %}
// If the user is editing their own account, make them confirm when email address is updated
{% if current_user.id == account.id %}
$('form#edit_user').submit(function () {
if ($('input#email_confirm').val() !== "") {
return confirm('Are you sure you want to change email address?\nYou will be logged out and will need to verify your account again to continue.');
}
});
{% endif %}
{# ~~->DontLeave:Feature~~ #}
// initialise the leave with unsaved changed warning
doaj.dontleave.init({containerSelector: "#edit_user"});
});
</script>
{% endblock extra_js_bottom %}