-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from membermatters/dev
v3.6.2
- Loading branch information
Showing
22 changed files
with
148 additions
and
138 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Python Linter (Black) | ||
|
||
on: [push, pull_request] | ||
on: [pull_request] | ||
|
||
jobs: | ||
lint-backend: | ||
|
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 21.8b0 | ||
rev: 24.1.1 | ||
hooks: | ||
- id: black | ||
language_version: python3 |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,56 @@ | ||
def userinfo(claims, user): | ||
# Populate claims dict. | ||
claims["name"] = "{0} {1}".format(user.profile.first_name, user.profile.last_name) | ||
claims["name"] = user.get_full_name() or "NO_NAME" | ||
claims["given_name"] = user.profile.first_name or "NO_FIRSTNAME" | ||
claims["family_name"] = user.profile.last_name or "NO_LASTNAME" | ||
claims["nickname"] = user.profile.screen_name or "NO_SCREENNAME" | ||
claims["preferred_username"] = user.profile.screen_name or "NO_SCREENNAME" | ||
claims["email"] = user.email | ||
claims["email_verified"] = user.email_verified | ||
claims["phone_number"] = user.profile.phone or "NO_PHONENUMBER" | ||
claims["phone_number_verified"] = False | ||
claims["updated_at"] = user.profile.modified.isoformat() | ||
|
||
return claims | ||
|
||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
from oidc_provider.lib.claims import ScopeClaims | ||
|
||
|
||
class CustomScopeClaims(ScopeClaims): | ||
info_membershipinfo = ( | ||
_("Membership Info"), | ||
_( | ||
"Current membership status, and other membership information like permissions/groups." | ||
), | ||
) | ||
|
||
def scope_membershipinfo(self): | ||
groups = [] | ||
state = self.user.profile.state | ||
subscription_state = self.user.profile.subscription_status | ||
subscriptionActive = subscription_state in ["active", "cancelling"] | ||
firstSubscribed = self.user.profile.subscription_first_created | ||
firstSubscribed = firstSubscribed.isoformat() if firstSubscribed else None | ||
|
||
if self.user.is_staff: | ||
groups.append("staff") | ||
|
||
if self.user.is_admin: | ||
groups.append("admin") | ||
|
||
if self.user.is_superuser: | ||
groups.append("superuser") | ||
|
||
if self.user.profile.state == "active": | ||
groups.append("active") | ||
|
||
return { | ||
"state": state, | ||
"active": state == "active", | ||
"subscriptionState": subscription_state, | ||
"subscriptionActive": subscriptionActive, | ||
"firstSubscribedDate": firstSubscribed, | ||
"groups": groups, | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
"""membermatters URL Configuration | ||
""" | ||
|
||
import os | ||
import django.db.utils | ||
from django.contrib import admin | ||
|
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
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
Oops, something went wrong.