-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Settings org 2 #5285
Settings org 2 #5285
Conversation
Organization - name - groups (Many to Many relationship to auth.Group) Model Updates: Profile - organizations (Many to Many relationship to dashboard.Organization) sync_profile updates: - updated to account for change to organizations referenced above New Management Command: - app/management/sync_orgs_repo.py - no arguments presently - designed to be run as a long running cron job
- Reverted the change around profile.organizations due to its usage in user hover cards Profile Model - organizations restored - orgs key added for the sync work
… and not lose permissions
- stale orgs and groups are now purged from users
… in profile.organizations against profile.orgs
Profile Model Class - repos added - ManyToMany on Repo Organization Class - repos added - ManyToMany on Repo Repos now synced through the sync command
… into feature/bounty-payout-4969
- added a scope variable that if set lets the scope path be queried for the user scope
(cherry picked from commit 0faf13e)
- switch to querying profiles and querying users where they exist - additional exception handling to database calls made inside the `recursive_sync` function
- additional exception handling and error messages to help debugging any issues with user profiles - private organizations should now correctly be capturable when they are granted access during login
- adding a per_page limit of 100 to the calls as a stop gap to proper pagination handling
Codecov Report
@@ Coverage Diff @@
## master #5285 +/- ##
=========================================
- Coverage 29.8% 29.61% -0.2%
=========================================
Files 236 237 +1
Lines 19891 20082 +191
Branches 2840 2873 +33
=========================================
+ Hits 5929 5947 +18
- Misses 13721 13890 +169
- Partials 241 245 +4
Continue to review full report at Codecov.
|
app/dashboard/views.py
Outdated
def org_perms(request): | ||
if request.user.is_authenticated and getattr(request.user, 'profile', None): | ||
profile = request.user.profile | ||
else: | ||
return JsonResponse( | ||
{'error': _('You must be authenticated via github to use this feature!')}, | ||
status=401) | ||
orgs = profile.profile_organizations.all() | ||
|
||
response_data = [] | ||
for org in orgs: | ||
print(org) | ||
org_perms = {'name': org.name, 'users': []} | ||
groups = org.groups.all().filter(user__isnull=False) | ||
for g in groups: # "admin", "write", "pull", "none" | ||
print(g) | ||
group_data = g.name.split('-') | ||
if group_data[1] != "role": #skip repo level groups | ||
continue | ||
print(g.user_set.prefetch_related('profile').all()) | ||
org_perms['users'].append( | ||
*[{'handle': u.profile.handle, | ||
'role': group_data[2], | ||
'name': '{} {}'.format(u.first_name, u.last_name)} | ||
for u in g.user_set.prefetch_related('profile').all()]) | ||
response_data.append(org_perms) | ||
return JsonResponse({'orgs': response_data}, safe=False) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danlipert I had changed a little the code from #5197
- added a missing comma as per the PR, - created a merge migration from the most recent master. Merge branch 'master' of github.com:gitcoinco/web into feature/bounty-payout-4969
Description
NOTE This depends on #5027 to be merged first
Refers/Fixes
fix #5160
fix #5130
Testing