Skip to content
Snippets Groups Projects
Verified Commit 1edb2c9a authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Nedestruktivni mazani skupin pri syncronizaci, individualni opravneni uzivatele

parent c0e7d9df
No related branches found
No related tags found
No related merge requests found
Pipeline #11127 passed
0.8.0
0.9.0
......@@ -31,8 +31,15 @@ sub callback ($c) {
my @groups = ();
my $permissions = {};
foreach my $permission ( @{ $user->permissions || [] } ) {
$permissions->{$permission} = 1;
}
my $groups = $c->schema->resultset('Group')->search(
{ octid => { '-in' => $octopus_user->{groups} }},
{
deleted => undef,
octid => { '-in' => $octopus_user->{groups} },
},
{ columns => ['id', 'permissions'] }
);
......
......@@ -6,7 +6,8 @@ sub list($c) {
my $args = $c->validation->output;
my $groups = $c->schema->resultset('Group')->search({
name => { ilike => '%' . $args->{search} . '%' }
name => { ilike => '%' . $args->{search} . '%' },
deleted => undef,
},
{
order_by => 'name',
......
......@@ -17,6 +17,7 @@ __PACKAGE__->add_columns(
sequence => 'uid_seq'
},
qw(
deleted
octid
name
permissions
......
......@@ -25,6 +25,7 @@ __PACKAGE__->add_columns(
uuid
username
displayname
permissions
),
);
......@@ -43,6 +44,12 @@ __PACKAGE__->has_many(
{ 'foreign.owner_id' => 'self.id', },
);
__PACKAGE__->inflate_column('permissions', {
inflate => sub {
return [ split /\W+/, shift ];
},
});
sub api_token {
my $self = shift;
my $args = shift;
......
......@@ -47,7 +47,9 @@ foreach my $group ( @{ $octopus_groups } ) {
}
# Cleanup
$schema->resultset('Group')->search({octid => {-not_in => \@exists}})->delete;
$schema->resultset('Group')->search({octid => {-not_in => \@exists}})->update({
deleted => \'now()'
});
# Update cache
my $meets = $schema->resultset('Meet')->search({deleted => undef});
......
......@@ -84,3 +84,9 @@ join "users" on ("users"."id" = "meets_users"."user_id")
-- 6 up
drop table "moderators";
alter table "users" drop column "octid";
-- 7 up
alter table "users" add column "permissions" text;
-- 8 up
alter table "groups" add column "deleted" timestamp(0);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment