Skip to content

Commit

Permalink
Feature/setup clr round 3 (#5161)
Browse files Browse the repository at this point in the history
* 	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
androolloyd authored and danlipert committed Sep 11, 2019
1 parent 1a78694 commit e1772c1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app/dashboard/management/commands/setup_grants_clr_3.py
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')
1 change: 1 addition & 0 deletions scripts/crontab
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/us

## USERS
0 1 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash set_user_personas >> /var/log/gitcoin/set_user_personas.log 2>&1
30 0 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash setup_grants_clr_3 >> /var/log/gitcoin/setup_clr_round_3.log 2>&1

0 comments on commit e1772c1

Please sign in to comment.