-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update_sortBy_component
- Loading branch information
Showing
45 changed files
with
1,062 additions
and
105 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
Empty file.
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,10 @@ | ||
"""Common GraphQL nodes.""" | ||
|
||
from graphene_django import DjangoObjectType | ||
|
||
|
||
class BaseNode(DjangoObjectType): | ||
"""Base node.""" | ||
|
||
class Meta: | ||
abstract = 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,7 @@ | ||
"""Common GraphQL queries.""" | ||
|
||
import graphene | ||
|
||
|
||
class BaseQuery(graphene.ObjectType): | ||
"""Base query.""" |
Empty file.
Empty file.
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,19 @@ | ||
"""GitHub issue GraphQL node.""" | ||
|
||
from apps.common.graphql.nodes import BaseNode | ||
from apps.github.models.issue import Issue | ||
|
||
|
||
class IssueNode(BaseNode): | ||
"""GitHub issue node.""" | ||
|
||
class Meta: | ||
model = Issue | ||
fields = ( | ||
"author", | ||
"comments_count", | ||
"created_at", | ||
"number", | ||
"state", | ||
"title", | ||
) |
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,23 @@ | ||
"""GitHub release GraphQL node.""" | ||
|
||
from graphene import Field | ||
|
||
from apps.common.graphql.nodes import BaseNode | ||
from apps.github.graphql.nodes.user import UserNode | ||
from apps.github.models.release import Release | ||
|
||
|
||
class ReleaseNode(BaseNode): | ||
"""GitHub release node.""" | ||
|
||
author = Field(UserNode) | ||
|
||
class Meta: | ||
model = Release | ||
fields = ( | ||
"author", | ||
"is_pre_release", | ||
"name", | ||
"published_at", | ||
"tag_name", | ||
) |
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,18 @@ | ||
"""GitHub user GraphQL node.""" | ||
|
||
from apps.common.graphql.nodes import BaseNode | ||
from apps.github.models.user import User | ||
|
||
|
||
class UserNode(BaseNode): | ||
"""GitHub user node.""" | ||
|
||
class Meta: | ||
model = User | ||
fields = ( | ||
"avatar_url", | ||
"email", | ||
"id", | ||
"login", | ||
"name", | ||
) |
Empty file.
Empty file.
Empty file.
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,29 @@ | ||
"""OWASP project GraphQL node.""" | ||
|
||
import graphene | ||
|
||
from apps.common.graphql.nodes import BaseNode | ||
from apps.github.graphql.nodes.issue import IssueNode | ||
from apps.github.graphql.nodes.release import ReleaseNode | ||
from apps.owasp.models.project import Project | ||
|
||
RECENT_ISSUES_LIMIT = 10 | ||
RECENT_RELEASES_LIMIT = 10 | ||
|
||
|
||
class ProjectNode(BaseNode): | ||
"""Project node.""" | ||
|
||
recent_issues = graphene.List(IssueNode) | ||
recent_releases = graphene.List(ReleaseNode) | ||
|
||
class Meta: | ||
model = Project | ||
|
||
def resolve_recent_issues(self, info): | ||
"""Resolve project recent issues.""" | ||
return self.issues.select_related("author").order_by("-created_at")[:RECENT_ISSUES_LIMIT] | ||
|
||
def resolve_recent_releases(self, info): | ||
"""Resolve project recent releases.""" | ||
return self.published_releases.order_by("-published_at")[:RECENT_RELEASES_LIMIT] |
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,7 @@ | ||
"""OWASP GraphQL queries.""" | ||
|
||
from apps.owasp.graphql.queries.project import ProjectQuery | ||
|
||
|
||
class OwaspQuery(ProjectQuery): | ||
"""OWASP queries.""" |
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,20 @@ | ||
"""OWASP project GraphQL queries.""" | ||
|
||
import graphene | ||
|
||
from apps.common.graphql.queries import BaseQuery | ||
from apps.owasp.graphql.nodes.project import ProjectNode | ||
from apps.owasp.models.project import Project | ||
|
||
|
||
class ProjectQuery(BaseQuery): | ||
"""Project queries.""" | ||
|
||
project = graphene.Field(ProjectNode, key=graphene.String(required=True)) | ||
|
||
def resolve_project(root, info, key): | ||
"""Resolve project by key.""" | ||
try: | ||
return Project.objects.get(key=key) | ||
except Project.DoesNotExist: | ||
return None |
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,9 +1,15 @@ | ||
from apps.slack.commands import ( | ||
board, | ||
chapters, | ||
committees, | ||
contribute, | ||
donate, | ||
gsoc, | ||
jobs, | ||
leaders, | ||
owasp, | ||
policies, | ||
projects, | ||
sponsors, | ||
staff, | ||
) |
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,28 @@ | ||
"""Slack bot board command.""" | ||
|
||
from django.conf import settings | ||
|
||
from apps.common.constants import NL | ||
from apps.slack.apps import SlackConfig | ||
from apps.slack.blocks import markdown | ||
|
||
COMMAND = "/board" | ||
|
||
|
||
def board_handler(ack, command, client): | ||
"""Slack /board command handler.""" | ||
ack() | ||
|
||
if not settings.SLACK_COMMANDS_ENABLED: | ||
return | ||
|
||
blocks = [ | ||
markdown(f"Please visit <https://owasp.org/www-board/|Global board> page{NL}"), | ||
] | ||
|
||
conversation = client.conversations_open(users=command["user_id"]) | ||
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks) | ||
|
||
|
||
if SlackConfig.app: | ||
board_handler = SlackConfig.app.command(COMMAND)(board_handler) |
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,30 @@ | ||
"""Slack bot donate command.""" | ||
|
||
from django.conf import settings | ||
|
||
from apps.common.constants import NL | ||
from apps.slack.apps import SlackConfig | ||
from apps.slack.blocks import markdown | ||
|
||
COMMAND = "/donate" | ||
|
||
|
||
def donate_handler(ack, command, client): | ||
"""Slack /donate command handler.""" | ||
ack() | ||
|
||
if not settings.SLACK_COMMANDS_ENABLED: | ||
return | ||
|
||
blocks = [ | ||
markdown( | ||
f"Please visit <https://owasp.org/donate/|donate to the OWASP Foundation> page{NL}" | ||
), | ||
] | ||
|
||
conversation = client.conversations_open(users=command["user_id"]) | ||
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks) | ||
|
||
|
||
if SlackConfig.app: | ||
donate_handler = SlackConfig.app.command(COMMAND)(donate_handler) |
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,29 @@ | ||
"""Slack bot jobs command.""" | ||
|
||
from django.conf import settings | ||
|
||
from apps.common.constants import NL | ||
from apps.slack.apps import SlackConfig | ||
from apps.slack.blocks import markdown | ||
from apps.slack.constants import OWASP_JOBS_CHANNEL_ID | ||
|
||
COMMAND = "/jobs" | ||
|
||
|
||
def jobs_handler(ack, command, client): | ||
"""Slack /jobs command handler.""" | ||
ack() | ||
|
||
if not settings.SLACK_COMMANDS_ENABLED: | ||
return | ||
|
||
blocks = [ | ||
markdown(f"Please join <{OWASP_JOBS_CHANNEL_ID}> channel{NL}"), | ||
] | ||
|
||
conversation = client.conversations_open(users=command["user_id"]) | ||
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks) | ||
|
||
|
||
if SlackConfig.app: | ||
jobs_handler = SlackConfig.app.command(COMMAND)(jobs_handler) |
Oops, something went wrong.