-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/funstats
- Loading branch information
Showing
40 changed files
with
1,378 additions
and
193 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,55 @@ | ||
name: 🚀 Feature Request | ||
description: Suggest an idea for this project | ||
title: "[FEATURE] <title>" | ||
labels: ["feature"] | ||
body: | ||
- type: checkboxes | ||
attributes: | ||
label: 👀 Is there an existing feature request for this? | ||
description: Please search to see if a feature request already exists for the feature you are suggesting. | ||
options: | ||
- label: I have searched the existing feature requests | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: 🌟 Feature statement | ||
description: What is your feature request? Please describe. | ||
placeholder: A clear and concise description of what the feature is. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: 👨👩👦 Is the feature related to some other issue or PR? | ||
description: Pleas give the isse or PR-number. | ||
placeholder: "#issue-number" or "#PR-number" | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: 💡 Proposed Solution | ||
description: Describe the solution you'd like | ||
placeholder: A clear and concise description of what you want to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: 🔦 Additional Context | ||
description: Add any other context or screenshots about the feature request here. | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: 🗺️ Where on Samfundet4 do you want the feature? | ||
description: Pleas give a file, or general "area" of Samfundet4 | ||
validations: | ||
required: true | ||
- type: dropdown | ||
attributes: | ||
label: Priority | ||
description: How important is this feature to you? | ||
options: | ||
- Nice to have | ||
- Important | ||
- Critical | ||
validations: | ||
required: true |
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,59 @@ | ||
name: 🐞 Bug | ||
description: File a bug/issue | ||
title: "[BUG] <title>" | ||
labels: ["Bug"] | ||
body: | ||
- type: checkboxes | ||
attributes: | ||
label: 👀 Is there an existing issue for this? | ||
description: Please search to see if an issue already exists for the bug you encountered. | ||
options: | ||
- label: I have searched the existing issues | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: 🚫 Current Behavior | ||
description: A concise description of what you're experiencing. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: ✅ Expected Behavior | ||
description: A concise description of what you expected to happen. | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: 🧩 Steps To Reproduce | ||
description: Steps to reproduce the behavior. | ||
placeholder: | | ||
1. In this environment... | ||
1. With this config... | ||
1. Run '...' | ||
1. See error... | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: 🐼 Environment | ||
description: | | ||
examples: | ||
- **OS**: Ubuntu 20.04 | ||
- **Node**: 13.14.0 | ||
- **npm**: 7.6.3 | ||
value: | | ||
- OS: | ||
- Node: | ||
- npm: | ||
render: markdown | ||
validations: | ||
required: false | ||
- type: textarea | ||
attributes: | ||
label: 🦮 Anything else? | ||
description: | | ||
Links? References? Anything that will give us more context about the issue you are encountering! | ||
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. | ||
validations: | ||
required: true |
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
Large diffs are not rendered by default.
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
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 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,37 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from django.contrib.auth.backends import BaseBackend | ||
|
||
from samfundet.utils import get_perm | ||
from samfundet.models import User | ||
from samfundet.models.role import UserOrgRole, UserGangRole, UserGangSectionRole | ||
|
||
|
||
class RoleAuthBackend(BaseBackend): | ||
def has_perm(self, user_obj: User, perm: str, obj: Any = None) -> bool: # noqa: C901 | ||
if not user_obj.is_active or obj is None: | ||
return False | ||
|
||
if user_obj.is_superuser: | ||
return True | ||
|
||
permission = get_perm(perm=perm, model=obj) | ||
|
||
if hasattr(obj, 'resolve_org'): | ||
org_id = obj.resolve_org(return_id=True) | ||
if org_id is not None and UserOrgRole.objects.filter(user=user_obj, obj__id=org_id, role__permissions=permission).exists(): | ||
return True | ||
|
||
if hasattr(obj, 'resolve_gang'): | ||
gang_id = obj.resolve_gang(return_id=True) | ||
if gang_id is not None and UserGangRole.objects.filter(user=user_obj, obj__id=gang_id, role__permissions=permission).exists(): | ||
return True | ||
|
||
if hasattr(obj, 'resolve_section'): | ||
section_id = obj.resolve_section(return_id=True) | ||
if section_id is not None and UserGangSectionRole.objects.filter(user=user_obj, obj__id=section_id, role__permissions=permission).exists(): | ||
return True | ||
|
||
return False |
Oops, something went wrong.