Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add realm acl roles to db dump #1110

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .deployment/files/realms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ blocks:
children:
- path: 'test-videos'
name: 'Test videos'
page_moderators:
- ROLE_USER
blocks:
- text: |
This page contains various additional test videos. And this text block
Expand Down Expand Up @@ -82,6 +84,10 @@ children:
children:
- path: 'betrieb'
name: 'Betrieb'
page_admins:
- ROLE_USER_SABINE
page_moderators:
- ROLE_USER_BJORK
children:
- { path: 'schluesseldelegierte', name: 'Schlüsseldelegierte' }
- { path: 'alumni', name: 'ETH Alumni Headquarter' }
Expand Down Expand Up @@ -116,6 +122,8 @@ children:
- { path: 'isn', name: 'International Relations and Security Network' }
- path: 'miscellaneous'
name: 'Miscellaneous'
page_admins:
- ROLE_STAFF
children:
- { path: 'iam', name: 'IAM' }
- { path: 'it-shop', name: 'IT-Shop' }
Expand Down Expand Up @@ -227,6 +235,8 @@ children:
- { path: 'unitedvisions', name: 'United Visions - Science City Magazin' }
- path: 'conferences'
name: 'Conferences'
page_moderators:
- ROLE_USER_MORGAN
blocks:
- text: |
Videos from conferences our university hosts. Like:
Expand Down Expand Up @@ -555,6 +565,8 @@ children:
- { path: 'zkm', name: 'ZKM/ELK-Tagung: Nachhaltige Schule' }
- path: 'events'
name: 'Events'
page_admins:
- ROLE_USER_SABINE
children:
- path: '2021'
name: '2021'
Expand Down Expand Up @@ -1247,6 +1259,9 @@ children:
- { path: '2012', name: '2012: Zehn Jahre NSL' }
- path: 'opencast'
name: 'Opencast'
page_moderators:
- ROLE_USER_MORGAN
- ROLE_USER_JOSE
children:
- path: '2021'
name: '2021'
Expand Down Expand Up @@ -1327,6 +1342,8 @@ children:
- { path: '2018', name: 'Venture 2018' }
- path: 'lectures'
name: 'Lectures'
page_admins:
- ROLE_USER_BJORK
blocks:
- text: |
Watch the recordings of all your favorite lectures! Knowledge at your fingertips.
Expand Down Expand Up @@ -1419,6 +1436,8 @@ children:
- { path: '103-0448-01L', name: 'Transformation of Urban Landscapes' }
- path: '2019'
name: '2019'
page_moderators:
- ROLE_USER_JOSE
children:
- path: 'autumn'
name: 'Autumn'
Expand Down Expand Up @@ -4537,6 +4556,11 @@ children:
- { path: '701-0005-00L', name: 'Technik der Problemlösung' }
- path: 'speakers'
name: 'Speakers'
page_admins:
- ROLE_USER_SABINE
- ROLE_USER_BJORK
page_moderators:
- ROLE_USER_MORGAN
children:
- { path: 'introductory-lectures', name: 'Antrittsvorlesungen' }
- path: 'bernays'
Expand Down Expand Up @@ -4809,6 +4833,8 @@ children:
- { path: 'd-bsse', name: 'D-BSSE: Lunch Meetings Molecular Systems Engineering' }
- path: 'd-infk'
name: 'D-INFK'
page_admins:
- ROLE_USER_JOSE
children:
- path: '2021'
name: '2021'
Expand Down Expand Up @@ -5094,6 +5120,8 @@ children:
- { path: 'documents', name: 'Support' }
- path: 'live'
name: 'Live'
page_moderators:
- ROLE_USER_MORGAN
blocks:
- text: |
Here are some never ending live streams!
Expand All @@ -5104,6 +5132,8 @@ children:
children:
- path: 'events'
name: 'Events'
page_admins:
- ROLE_STAFF
children:
- { path: 'live-1', name: 'ETH Live 1' }
- { path: 'live-2', name: 'ETH Live 2' }
Expand Down
16 changes: 16 additions & 0 deletions backend/src/cmd/import_realm_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ struct Realm {

#[serde(default)]
children: Vec<Realm>,

#[serde(default)]
page_admins: Vec<String>,

#[serde(default)]
page_moderators: Vec<String>,
}

#[derive(Debug, Deserialize, Clone)]
Expand Down Expand Up @@ -220,6 +226,16 @@ fn insert_realm<'a>(
}
}

// Insert acl roles
if !realm.page_admins.is_empty() || !realm.page_moderators.is_empty() {
let query = "update realms \
set admin_roles = $1, moderator_roles = ($1::text[] || $2) \
where id = $3 \
";
db.execute(query, &[&realm.page_admins, &realm.page_moderators, &id]).await?;
}


match name_source_block_id {
Some(block_id) => {
let query = "update realms \
Expand Down
Loading