Plume/templates/users/edit.rs.html
Ana Gelez 309e1200d0 Make a distinction between moderators and admins (#619)
* 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
2019-09-13 12:28:36 +02:00

64 lines
2.7 KiB
HTML

@use templates::base;
@use template_utils::*;
@use plume_models::instance::Instance;
@use routes::user::UpdateUserForm;
@use validator::ValidationErrors;
@use routes::*;
@(ctx: BaseContext, form: UpdateUserForm, errors: ValidationErrors)
@:base(ctx, i18n!(ctx.1, "Edit your account"), {}, {}, {
@if let Some(u) = ctx.2.clone() {
<h1>@i18n!(ctx.1, "Your Profile")</h1>
<p>
@i18n!(ctx.1, "To change your avatar, upload it to your gallery and then select from there.")
<a href="@uri!(medias::new)">@i18n!(ctx.1, "Upload an avatar")</a>
</p>
<form method="post" action="@uri!(user::update: _name = u.username.clone())">
<!-- Rocket hack to use various HTTP methods -->
<input type=hidden name="_method" value="put">
@(Input::new("display_name", i18n!(ctx.1, ""))
.default(&form.display_name)
.error(&errors)
.html(ctx.1))
@(Input::new("email", i18n!(ctx.1, ""))
.default(&form.email)
.error(&errors)
.input_type("email")
.html(ctx.1))
<label for="summary">@i18n!(ctx.1, "Summary")</label>
<textarea id="summary" name="summary">@form.summary</textarea>
@if let Ok(themes) = Instance::list_themes() {
<label for="theme">@i18n!(ctx.1, "Theme")</label>
<select name="theme" id="theme">
<option value="" @if form.theme.is_none() { selected }>@i18n!(ctx.1, "Default theme")</option>
@for theme in themes {
<option value="@theme" @if Some(theme.clone()) == form.theme { selected }>@theme</option>
}
</select>
} else {
<p class="error">@i18n!(ctx.1, "Error while loading theme selector.")</p>
}
<label for="hide_custom_css">
<input type="checkbox" name="hide_custom_css" id="hide_custom_css" @if form.hide_custom_css { checked }>
@i18n!(ctx.1, "Never load blogs custom themes")
</label>
<input type="submit" value="@i18n!(ctx.1, "Update account")"/>
</form>
<h2>@i18n!(ctx.1, "Danger zone")</h2>
<p>@i18n!(ctx.1, "Be very careful, any action taken here can't be cancelled.")
@if !u.is_admin() {
<form method="post" action="@uri!(user::delete: name = u.username)">
<input type="submit" class="inline-block button destructive" value="@i18n!(ctx.1, "Delete your account")">
</form>
} else {
<p>@i18n!(ctx.1, "Sorry, but as an admin, you can't leave your own instance.")</p>
}
}
})