Skip to content
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

Merged
merged 50 commits into from
Oct 23, 2019
Merged

Settings org 2 #5285

merged 50 commits into from
Oct 23, 2019

Conversation

octavioamu
Copy link
Contributor

@octavioamu octavioamu commented Oct 1, 2019

Description

NOTE This depends on #5027 to be merged first
image

Refers/Fixes

fix #5160
fix #5130

Testing

androolloyd and others added 30 commits August 16, 2019 16:25
	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
	- 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
	- 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
androolloyd and others added 7 commits September 30, 2019 23:03
	- 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
Copy link

codecov bot commented Oct 2, 2019

Codecov Report

Merging #5285 into master will decrease coverage by 0.19%.
The diff coverage is 15.04%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
app/app/urls.py 89.58% <ø> (ø) ⬆️
app/app/utils.py 23.13% <0%> (-0.09%) ⬇️
app/app/management/commands/sync_orgs_repos.py 0% <0%> (ø)
app/app/settings.py 79.19% <100%> (ø) ⬆️
app/marketing/views.py 11.86% <20%> (-0.02%) ⬇️
app/dashboard/views.py 12.91% <28.57%> (+0.01%) ⬆️
app/git/utils.py 40.19% <36.66%> (-1.59%) ⬇️
app/dashboard/utils.py 40.25% <6.25%> (-1.23%) ⬇️
app/dashboard/models.py 50.67% <87.5%> (+0.22%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bc7e53...935c579. Read the comment docs.

Comment on lines 99 to 127
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)


Copy link
Contributor Author

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

@octavioamu octavioamu marked this pull request as ready for review October 2, 2019 23:00
octavioamu and others added 6 commits October 22, 2019 12:06
- 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
@danlipert danlipert merged commit a7f7dff into master Oct 23, 2019
@thelostone-mc thelostone-mc deleted the settings-org-2 branch June 27, 2020 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants