Skip to content

Commit

Permalink
Merge branch 'main' into update_sortBy_component
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajgupta36 authored Jan 26, 2025
2 parents 0efb08a + b5e28bb commit 8bf0537
Show file tree
Hide file tree
Showing 45 changed files with 1,062 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ jobs:
echo "VITE_ALGOLIA_SEARCH_API_KEY=${{ secrets.VITE_ALGOLIA_SEARCH_API_KEY }}" >> frontend/.env.staging
echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" >> frontend/.env.staging
echo "VITE_ENVIRONMENT=${{ secrets.VITE_ENVIRONMENT }}" >> frontend/.env.staging
echo "VITE_GRAPHQL_URL=${{ secrets.VITE_GRAPHQL_URL }}" >> frontend/.env.staging
echo "VITE_RELEASE_VERSION=$(date '+%y.%-m.%-d')-${GITHUB_SHA:0:7}" >> frontend/.env.staging
echo "VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> frontend/.env.staging
Expand Down Expand Up @@ -335,6 +336,7 @@ jobs:
echo "VITE_ALGOLIA_SEARCH_API_KEY=${{ secrets.ALGOLIA_SEARCH_API_KEY }}" >> frontend/.env.production
echo "VITE_API_URL=https://nest.owasp.org/api/v1" >> frontend/.env.production
echo "VITE_ENVIRONMENT=production" >> frontend/.env.production
echo "VITE_GRAPHQL_URL=${{ secrets.VITE_GRAPHQL_URL }}" >> frontend/.env.staging
echo "VITE_RELEASE_VERSION=${{ github.event.release.tag_name }}" >> frontend/.env.production
echo "VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> frontend/.env.production
Expand Down
Empty file.
10 changes: 10 additions & 0 deletions backend/apps/common/graphql/nodes.py
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
7 changes: 7 additions & 0 deletions backend/apps/common/graphql/queries.py
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.
19 changes: 19 additions & 0 deletions backend/apps/github/graphql/nodes/issue.py
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",
)
23 changes: 23 additions & 0 deletions backend/apps/github/graphql/nodes/release.py
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",
)
18 changes: 18 additions & 0 deletions backend/apps/github/graphql/nodes/user.py
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.
29 changes: 29 additions & 0 deletions backend/apps/owasp/graphql/nodes/project.py
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]
7 changes: 7 additions & 0 deletions backend/apps/owasp/graphql/queries/__init__.py
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."""
20 changes: 20 additions & 0 deletions backend/apps/owasp/graphql/queries/project.py
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
5 changes: 5 additions & 0 deletions backend/apps/owasp/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def is_indexable(self):
"""Projects to index."""
return self.has_active_repositories

@property
def issues(self):
"""Return issues."""
return Issue.objects.filter(repository__in=self.repositories.all())

@property
def nest_key(self):
"""Get Nest key."""
Expand Down
50 changes: 37 additions & 13 deletions backend/apps/slack/MANIFEST.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@ features:
display_name: NestBot
always_online: true
slash_commands:
- command: /owasp
url: https://nest.owasp.dev/integrations/slack/commands/
description: your gateway to OWASP
usage_hint: --help
should_escape: false
- command: /projects
url: https://nest.owasp.dev/integrations/slack/commands/
description: project directory
usage_hint: <search query>
should_escape: false
- command: /leaders
url: https://nest.owasp.dev/integrations/slack/commands/
description: chapter and project leaders
usage_hint: <name/chapter/project>
should_escape: false
- command: /committees
url: https://nest.owasp.dev/integrations/slack/commands/
description: committees
Expand All @@ -36,15 +26,49 @@ features:
description: chapters
usage_hint: --help
should_escape: false
- command: /gsoc
url: https://nest.owasp.dev/integrations/slack/commands/
description: get started with GSoC program
usage_hint: --start
should_escape: false
- command: /owasp
url: https://nest.owasp.dev/integrations/slack/commands/
description: your gateway to OWASP
usage_hint: --help
should_escape: false
- command: /leaders
url: https://nest.owasp.dev/integrations/slack/commands/
description: chapter and project leaders
usage_hint: <name/chapter/project>
should_escape: false
- command: /contribute
url: https://nest.owasp.dev/integrations/slack/commands/
description: contributor's guide
usage_hint: --help
should_escape: false
- command: /gsoc
- command: /board
url: https://nest.owasp.dev/integrations/slack/commands/
description: get started with GSoC program
usage_hint: --start
description: OWASP Global Board information
should_escape: false
- command: /donate
url: https://nest.owasp.dev/integrations/slack/commands/
description: Support OWASP with a donation
should_escape: false
- command: /jobs
url: https://nest.owasp.dev/integrations/slack/commands/
description: Check out available job opportunities
should_escape: false
- command: /sponsors
url: https://nest.owasp.dev/integrations/slack/commands/
description: et a list of OWASP sponsors
should_escape: false
- command: /staff
url: https://nest.owasp.dev/integrations/slack/commands/
description: OWASP corporate structure
should_escape: false
- command: /policies
url: https://nest.owasp.dev/integrations/slack/commands/
description: Policies & Procedures
should_escape: false
oauth_config:
scopes:
Expand Down
6 changes: 6 additions & 0 deletions backend/apps/slack/commands/__init__.py
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,
)
28 changes: 28 additions & 0 deletions backend/apps/slack/commands/board.py
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)
30 changes: 30 additions & 0 deletions backend/apps/slack/commands/donate.py
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)
29 changes: 29 additions & 0 deletions backend/apps/slack/commands/jobs.py
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)
Loading

0 comments on commit 8bf0537

Please sign in to comment.