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
This commit is contained in:
Ana Gelez
2019-09-13 12:28:36 +02:00
committed by Igor Galić
parent 12c80f9981
commit 309e1200d0
44 changed files with 11437 additions and 10408 deletions
@@ -0,0 +1,4 @@
-- This file should undo anything in `up.sql`
ALTER TABLE users ADD COLUMN is_admin BOOLEAN NOT NULL DEFAULT 'f';
UPDATE users SET is_admin = 't' WHERE role = 0;
ALTER TABLE users DROP COLUMN role;
@@ -0,0 +1,4 @@
-- Your SQL goes here
ALTER TABLE users ADD COLUMN role INTEGER NOT NULL DEFAULT 2;
UPDATE users SET role = 0 WHERE is_admin = 't';
ALTER TABLE users DROP COLUMN is_admin;