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) { ...@@ -31,8 +31,15 @@ sub callback ($c) {
my @groups = (); my @groups = ();
my $permissions = {}; my $permissions = {};
foreach my $permission ( @{ $user->permissions || [] } ) {
$permissions->{$permission} = 1;
}
my $groups = $c->schema->resultset('Group')->search( my $groups = $c->schema->resultset('Group')->search(
{ octid => { '-in' => $octopus_user->{groups} }}, {
deleted => undef,
octid => { '-in' => $octopus_user->{groups} },
},
{ columns => ['id', 'permissions'] } { columns => ['id', 'permissions'] }
); );
......
...@@ -6,7 +6,8 @@ sub list($c) { ...@@ -6,7 +6,8 @@ sub list($c) {
my $args = $c->validation->output; my $args = $c->validation->output;
my $groups = $c->schema->resultset('Group')->search({ my $groups = $c->schema->resultset('Group')->search({
name => { ilike => '%' . $args->{search} . '%' } name => { ilike => '%' . $args->{search} . '%' },
deleted => undef,
}, },
{ {
order_by => 'name', order_by => 'name',
......
...@@ -17,6 +17,7 @@ __PACKAGE__->add_columns( ...@@ -17,6 +17,7 @@ __PACKAGE__->add_columns(
sequence => 'uid_seq' sequence => 'uid_seq'
}, },
qw( qw(
deleted
octid octid
name name
permissions permissions
......
...@@ -25,6 +25,7 @@ __PACKAGE__->add_columns( ...@@ -25,6 +25,7 @@ __PACKAGE__->add_columns(
uuid uuid
username username
displayname displayname
permissions
), ),
); );
...@@ -43,6 +44,12 @@ __PACKAGE__->has_many( ...@@ -43,6 +44,12 @@ __PACKAGE__->has_many(
{ 'foreign.owner_id' => 'self.id', }, { 'foreign.owner_id' => 'self.id', },
); );
__PACKAGE__->inflate_column('permissions', {
inflate => sub {
return [ split /\W+/, shift ];
},
});
sub api_token { sub api_token {
my $self = shift; my $self = shift;
my $args = shift; my $args = shift;
......
...@@ -47,7 +47,9 @@ foreach my $group ( @{ $octopus_groups } ) { ...@@ -47,7 +47,9 @@ foreach my $group ( @{ $octopus_groups } ) {
} }
# Cleanup # Cleanup
$schema->resultset('Group')->search({octid => {-not_in => \@exists}})->delete; $schema->resultset('Group')->search({octid => {-not_in => \@exists}})->update({
deleted => \'now()'
});
# Update cache # Update cache
my $meets = $schema->resultset('Meet')->search({deleted => undef}); my $meets = $schema->resultset('Meet')->search({deleted => undef});
......
...@@ -84,3 +84,9 @@ join "users" on ("users"."id" = "meets_users"."user_id") ...@@ -84,3 +84,9 @@ join "users" on ("users"."id" = "meets_users"."user_id")
-- 6 up -- 6 up
drop table "moderators"; drop table "moderators";
alter table "users" drop column "octid"; 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.
Please register or to comment