Add a few (ugly) badges to the user page

This commit is contained in:
Bat 2018-05-12 17:55:25 +01:00
parent ea08718c23
commit aefa31b84e
3 changed files with 41 additions and 12 deletions

View File

@ -23,6 +23,8 @@ fn me(user: User) -> Redirect {
fn details(name: String, conn: DbConn, account: Option<User>) -> Template { fn details(name: String, conn: DbConn, account: Option<User>) -> Template {
let user = User::find_by_fqn(&*conn, name).unwrap(); let user = User::find_by_fqn(&*conn, name).unwrap();
let recents = Post::get_recents_for_author(&*conn, &user, 5); let recents = Post::get_recents_for_author(&*conn, &user, 5);
let user_id = user.id.clone();
Template::render("users/details", json!({ Template::render("users/details", json!({
"user": serde_json::to_value(user).unwrap(), "user": serde_json::to_value(user).unwrap(),
"account": account, "account": account,
@ -33,7 +35,8 @@ fn details(name: String, conn: DbConn, account: Option<User>) -> Template {
"url": p.compute_id(&*conn), "url": p.compute_id(&*conn),
"date": p.creation_date.timestamp() "date": p.creation_date.timestamp()
}) })
}).collect::<Vec<serde_json::Value>>() }).collect::<Vec<serde_json::Value>>(),
"is_self": account.map(|a| a.id == user_id).unwrap_or(false)
})) }))
} }

View File

@ -91,3 +91,13 @@ textarea {
min-height: 200px; min-height: 200px;
resize: vertical; resize: vertical;
} }
.badge {
font-size: 12pt;
background: white;
color: #7a28cb;
border: 1px solid #7a28cb;
border-radius: 3px;
padding: 5px 10px;
margin: 0px 10px;
}

View File

@ -5,7 +5,23 @@
{% endblock title %} {% endblock title %}
{% block content %} {% block content %}
<h1>{{ user.display_name }}</h1> <div>
<h1>
{{ user.display_name }}
{% if user.is_admin %}
<span class="badge">Admin</span>
{% endif %}
{% if is_self %}
<span class="badge">It is you</span>
{% endif %}
</h1>
{% if is_self %}
<a href="edit" class="button inline-block">Edit your profile</a>
{% endif %}
</div>
<div> <div>
{{ user.summary | safe }} {{ user.summary | safe }}
</div> </div>