-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathprofile.rs
More file actions
220 lines (212 loc) · 9.54 KB
/
Copy pathprofile.rs
File metadata and controls
220 lines (212 loc) · 9.54 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
use crate::components::P;
use log::error;
use maud::{html, Markup, PreEscaped};
use pointercrate_core::{error::PointercrateError, localization::tr, permission::PermissionsManager, trp};
use pointercrate_core_pages::{
error::ErrorFragment,
trp_html,
util::{filtered_paginator, paginator},
};
use pointercrate_demonlist::player::claim::PlayerClaim;
use pointercrate_user::{
auth::{AuthenticatedUser, NonMutating},
MODERATOR,
};
use pointercrate_user_pages::account::AccountPageTab;
use sqlx::PgConnection;
pub struct ProfileTab(#[doc = "discord invite url"] pub &'static str);
#[async_trait::async_trait]
impl AccountPageTab for ProfileTab {
fn should_display_for(&self, _permissions_we_have: u16, _permissions: &PermissionsManager) -> bool {
true
}
fn initialization_script(&self) -> String {
"/static/demonlist/js/account/profile.js".into()
}
fn tab_id(&self) -> u8 {
7
}
fn tab(&self) -> Markup {
html! {
b {
(tr("profile"))
}
(PreEscaped(" "))
i class = "fa fa-user fa-2x" aria-hidden="true" {}
}
}
async fn content(
&self, user: &AuthenticatedUser<NonMutating>, permissions: &PermissionsManager, connection: &mut PgConnection,
) -> Markup {
let player_claim = match PlayerClaim::by_user(user.user().id, connection).await {
Ok(player_claim) => player_claim,
Err(err) => {
error!("Error retrieving player claim of user {}: {:?}", user.user(), err);
return ErrorFragment {
status: err.status_code(),
reason: "Internal Server Error".to_string(),
message: err.to_string(),
}
.body();
},
};
let is_moderator = permissions.require_permission(user.user().permissions, MODERATOR).is_ok();
html! {
div.left {
div.panel.fade.js-collapse style="text-align: left; padding: 10px 20px" {
div.flex.no-stretch style="justify-content: space-between; align-items: center; " {
span style = "font-size: 1.3em" {
i.fa.fa-pencil-alt.clickable #player-claim-pen aria-hidden = "true" {} (PreEscaped(" "))
b {
(tr("claimed-player")) ": "
}
@match player_claim {
Some(ref claim) => {
(P(&claim.player, Some("claimed-player")))
},
None => {
i {
"None"
}
}
}
}
span {
@match player_claim {
Some(ref claim) if claim.verified => {
i style="margin-right: 15px;" {
(tr("claimed-player.verified"))
}
span.arrow.hover {}
},
Some(_) => i{(tr("claimed-player.unverified"))},
_ => {}
}
}
}
@if let Some(ref claim) = player_claim {
@if claim.verified {
div.overlined.pad.js-collapse-content #claims-claim-panel style="display:none" {
// It'd be neat to eliminate this feature and instead have this tied to the presence of a Box<dyn GeolocationProvider> state, but
// plumbing that information all the way here is... hella complicated.
@if cfg!(feature = "geolocation") {
p.info-red.output style = "margin: 10px 0" {}
p.info-green.output style = "margin: 10px 0" {}
div.flex.no-stretch style="justify-content: space-between; align-items: center" {
b {
(tr("claim-geolocate"))
}
a.button.blue.hover #claims-geolocate-nationality {
(tr("claim-geolocate.submit"))
}
}
p {
(tr("claim-geolocate.info"))
}
}
div.cb-container.flex.no-stretch style="justify-content: space-between; align-items: center" {
b {
(tr("claim-lock-submissions"))
}
@if claim.lock_submissions {
input #lock-submissions-checkbox type = "checkbox" name = "lock_submissions" checked = "";
}
@else {
input #lock-submissions-checkbox type = "checkbox" name = "lock_submissions";
}
span.checkmark {}
}
p {
(tr("claim-lock-submissions.info"))
}
}
}
}
}
@if let Some(claim) = player_claim {
@if claim.verified {
div.panel.fade {
h2.pad.underlined {
(tr("claim-records"))
}
p {
(PreEscaped(trp!(
"claim-records.info",
"record-approved-styled" = html! {
span.ok { (tr("record-approved")) }
}.into_string(),
"record-submitted-styled" = html! {
span.warn { (tr("record-submitted")) }
}.into_string(),
"record-rejected-styled" = html! {
span.err { (tr("record-rejected")) }
}.into_string(),
"record-underconsideration-styled" = html! {
span.consider { (tr("record-underconsideration")) }
}.into_string()
)))
}
(paginator("claims-record-pagination", "/api/v1/records/"))
}
}
}
@if is_moderator {
div.panel.fade {
h2.pad.underlined {
(tr("claim-manager"))
}
p {
(tr("claim-manager.info-a"))
br;
(tr("claim-manager.info-b"))
br;
(tr("claim-manager.info-c"))
br;
(tr("claim-manager.info-d"))
}
(filtered_paginator("claim-pagination", "/api/v1/players/claims/"))
}
}
}
div.right {
div.panel.fade style = "display: none;"{
h2.underlined.pad {
(tr("claim-initiate-panel"))
}
p {
(tr("claim-initiate-panel.info"))
}
(filtered_paginator("claims-initiate-claim-pagination", "/api/v1/players/"))
}
div.panel.fade {
h2.underlined.pad {
(tr("claim-info-panel"))
}
p {
(tr("claim-info-panel.info-a"))
br;
(trp_html!(
"claim-info-panel.info-b",
"discord" = html! {
a.link href = (&self.0) { (tr("claim-info-panel.info-discord")) }
}
))
br;
(tr("claim-info-panel.info-c"))
}
}
@if is_moderator {
div.panel.fade {
h2.underlined.pad {
(tr("claim-video-panel"))
}
p {
(tr("claim-video-panel.info"))
}
iframe."ratio-16-9"#claim-video style="width:100%;" allowfullscreen="" {}
}
}
}
}
}
}