-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Setup CLR Command - add valid users to the newly created Grants-CLR-Round-3 - valid user filter set for the 1st of March 2019 * added a filter to exclude users who have already been added to the clr round 3 group * updated date to proper round 3 cutoff * sorted imports to appease jenkins * adding a cron to execute the setup_clr_round_3 job every day at 1230 AM * fix the mgmt job name
- Loading branch information
1 parent
1a78694
commit e1772c1
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
''' | ||
Copyright (C) 2018 Gitcoin Core | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' | ||
from django.contrib.auth.models import Group, Permission, User | ||
from django.core.management.base import BaseCommand | ||
from django.db.models import Q | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Setup CLR Round 3" | ||
|
||
def handle(self, *args, **options): | ||
clr_r3_group_name = "Grants-CLR-Round-3" | ||
clr_group_r3 = Group.objects.get_or_create(name=clr_r3_group_name)[0] | ||
add_clr_match = Permission.objects.get(codename="add_clrmatch") | ||
clr_group_r3.permissions.add(add_clr_match) | ||
|
||
print('Fetching Valid Grant CLR Round 3 Users') | ||
valid_users = User.objects.filter(~Q(groups__name__in=[clr_r3_group_name]), | ||
profile__data__created_at__lte="2019-02-15") | User.objects.filter( | ||
~Q(groups__name__in=[clr_r3_group_name]), profile__trust_profile=True) | ||
for user in valid_users: | ||
user.groups.add(clr_group_r3) | ||
|
||
print('Grant CLR Round 3 Setup Finished') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters