309e1200d0
* Make a distinction between moderators and admins And rework the user list in the moderation interface, to be able to run the same action on many users, and to have a huge list of actions whithout loosing space. * Make user's role an enum + make it impossible for a moderator to escalate privileges With the help of diesel-derive-enum (maybe it could be used in other places too?) Also, moderators are still able to grant or revoke moderation rights to other people, but maybe only admins should be able to do it? * Cargo fmt * copy/pasting is bad * Remove diesel-derive-enum and use an integer instead It was not compatible with both Postgres and SQlite, because for one it generated a schema with the "User_role" type, but for the other it was "Text"… * Reset translations * Use an enum to avoid magic numbers + fix the tests * Reset translations * Fix down.sql
50 lines
2.0 KiB
HTML
50 lines
2.0 KiB
HTML
@use plume_models::users::User;
|
|
@use templates::base;
|
|
@use template_utils::*;
|
|
@use routes::*;
|
|
|
|
@(ctx: BaseContext, users: Vec<User>, page: i32, n_pages: i32)
|
|
|
|
@:base(ctx, i18n!(ctx.1, "Users"), {}, {}, {
|
|
<h1>@i18n!(ctx.1, "Users")</h1>
|
|
|
|
@tabs(&[
|
|
(&uri!(instance::admin).to_string(), i18n!(ctx.1, "Configuration"), false),
|
|
(&uri!(instance::admin_instances: page = _).to_string(), i18n!(ctx.1, "Instances"), false),
|
|
(&uri!(instance::admin_users: page = _).to_string(), i18n!(ctx.1, "Users"), true),
|
|
])
|
|
|
|
<form method="post" action="@uri!(instance::edit_users)">
|
|
<header>
|
|
<select name="action">
|
|
<option value="admin">@i18n!(ctx.1, "Grant admin rights")</option>
|
|
<option value="un-admin">@i18n!(ctx.1, "Revoke admin rights")</option>
|
|
<option value="moderator">@i18n!(ctx.1, "Grant moderator rights")</option>
|
|
<option value="un-moderator">@i18n!(ctx.1, "Revoke moderator rights")</option>
|
|
<option value="ban">@i18n!(ctx.1, "Ban")</option>
|
|
</select>
|
|
<input type="submit" value="@i18n!(ctx.1, "Run on selected users")">
|
|
</header>
|
|
<div class="list">
|
|
@for user in users {
|
|
<div class="card flex compact">
|
|
<input type="checkbox" name="@user.id">
|
|
@avatar(ctx.0, &user, Size::Small, false, ctx.1)
|
|
<p class="grow">
|
|
<a href="@uri!(user::details: name = &user.fqn)">@user.name()</a>
|
|
<small>@format!("@{}", user.username)</small>
|
|
</p>
|
|
@if user.is_admin() {
|
|
<p class="badge">@i18n!(ctx.1, "Admin")</p>
|
|
} else {
|
|
@if user.is_moderator() {
|
|
<p class="badge">@i18n!(ctx.1, "Moderator")</p>
|
|
}
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
</form>
|
|
@paginate(ctx.1, page, n_pages)
|
|
})
|