Skip to content

Commit 28c1a17

Browse files
authored
Merge branch 'main' into Improve-NestBot-/users-command
2 parents d855cf1 + 67bd336 commit 28c1a17

File tree

108 files changed

+2037
-647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+2037
-647
lines changed

.github/labeler.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ docker:
3131
- 'docker-*.yaml'
3232
- '**/Dockerfile.*'
3333

34-
documentation:
34+
docs:
3535
- changed-files:
3636
- any-glob-to-any-file:
3737
- '**/*.md'
@@ -67,11 +67,12 @@ nginx:
6767
- 'nginx/**'
6868

6969
schema:
70-
- changed-files:
71-
- any-glob-to-any-file:
72-
- 'schema/**'
73-
- all-globs-to-all-files:
74-
- '!schema/tests/**'
70+
- all:
71+
- changed-files:
72+
- any-glob-to-any-file:
73+
- 'schema/**'
74+
- all-globs-to-all-files:
75+
- '!schema/tests/**'
7576

7677
schema-tests:
7778
- changed-files:

.pre-commit-config.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,3 @@ repos:
3434
entry: djlint --reformat
3535
types:
3636
- html
37-
38-
- repo: https://github.com/pycqa/isort
39-
rev: 5.13.2
40-
hooks:
41-
- id: isort

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Follow these steps to set up the OWASP Nest application:
106106
```
107107

108108
- Leave this terminal session running and wait until you see that [Nest local](http://localhost:8000/api/v1) is responding.
109-
- Please note as we use containerazed approach this command must be run in parallel to other Nest commands you may want to use. You need to keep it running in the current terminal and use another terminal session for your work.
109+
- Please note as we use containerized approach this command must be run in parallel to other Nest commands you may want to use. You need to keep it running in the current terminal and use another terminal session for your work.
110110

111111
1. **Load Initial Data**:
112112
- Open a new terminal session and run the following command to populate the database with initial data from fixtures:
@@ -185,7 +185,7 @@ To setup NestBot development environment, follow these steps:
185185
hostname: <your-static-domain>
186186
```
187187

188-
- Now ngrok is all set, you access your local setup over internet, running the follwing command:
188+
- Now ngrok is all set, you access your local setup over internet, running the following command:
189189

190190
```bash
191191
ngrok start NestBot
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""GitHub repository GraphQL node."""
2+
3+
import graphene
4+
5+
from apps.common.graphql.nodes import BaseNode
6+
from apps.github.models.repository import Repository
7+
8+
9+
class RepositoryNode(BaseNode):
10+
"""GitHub repository node."""
11+
12+
url = graphene.String()
13+
14+
class Meta:
15+
model = Repository
16+
fields = (
17+
"name",
18+
"forks_count",
19+
"stars_count",
20+
"open_issues_count",
21+
"subscribers_count",
22+
"contributors_count",
23+
)
24+
25+
def resolve_url(self, info):
26+
"""Resolve URL."""
27+
return self.url

backend/apps/github/index/issue.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ def get_queryset(self):
9494
@staticmethod
9595
def update_synonyms():
9696
"""Update synonyms."""
97-
return IssueIndex.reindex_synonyms("github", "issues")
97+
return IssueIndex.reindex_synonyms("github", "issue")

backend/apps/github/models/repository.py

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ def top_languages(self):
135135
if v >= LANGUAGE_PERCENTAGE_THRESHOLD and k.lower() not in IGNORED_LANGUAGES
136136
)
137137

138+
@property
139+
def url(self):
140+
"""Return repository URL."""
141+
return f"https://github.com/{self.path}"
142+
138143
def from_github(
139144
self,
140145
gh_repository,

backend/apps/owasp/admin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ChapterAdmin(admin.ModelAdmin, GenericEntityAdminMixin):
4848
search_fields = ("name", "key")
4949

5050

51-
class CommetteeAdmin(admin.ModelAdmin):
51+
class CommitteeAdmin(admin.ModelAdmin):
5252
autocomplete_fields = ("owasp_repository",)
5353
search_fields = ("name",)
5454

@@ -102,6 +102,6 @@ def custom_field_name(self, obj):
102102

103103

104104
admin.site.register(Chapter, ChapterAdmin)
105-
admin.site.register(Committee, CommetteeAdmin)
105+
admin.site.register(Committee, CommitteeAdmin)
106106
admin.site.register(Event, EventAdmin)
107107
admin.site.register(Project, ProjectAdmin)

backend/apps/owasp/graphql/nodes/project.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.common.graphql.nodes import BaseNode
66
from apps.github.graphql.nodes.issue import IssueNode
77
from apps.github.graphql.nodes.release import ReleaseNode
8+
from apps.github.graphql.nodes.repository import RepositoryNode
89
from apps.owasp.models.project import Project
910

1011
RECENT_ISSUES_LIMIT = 10
@@ -16,6 +17,7 @@ class ProjectNode(BaseNode):
1617

1718
recent_issues = graphene.List(IssueNode)
1819
recent_releases = graphene.List(ReleaseNode)
20+
repositories = graphene.List(RepositoryNode)
1921

2022
class Meta:
2123
model = Project
@@ -28,3 +30,7 @@ def resolve_recent_issues(self, info):
2830
def resolve_recent_releases(self, info):
2931
"""Resolve project recent releases."""
3032
return self.published_releases.order_by("-published_at")[:RECENT_RELEASES_LIMIT]
33+
34+
def resolve_repositories(self, info):
35+
"""Resolve repositories."""
36+
return self.repositories.order_by("-pushed_at", "-updated_at")

backend/apps/owasp/index/project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_queryset(self):
9191
@staticmethod
9292
def update_synonyms():
9393
"""Update synonyms."""
94-
return ProjectIndex.reindex_synonyms("owasp", "projects")
94+
return ProjectIndex.reindex_synonyms("owasp", "project")
9595

9696
@staticmethod
9797
def configure_replicas():

backend/apps/owasp/models/chapter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from apps.common.utils import join_values
1212
from apps.core.models.prompt import Prompt
1313
from apps.owasp.models.common import GenericEntityModel, RepositoryBasedEntityModel
14-
from apps.owasp.models.managers.chapter import ActiveChaptertManager
14+
from apps.owasp.models.managers.chapter import ActiveChapterManager
1515
from apps.owasp.models.mixins.chapter import ChapterIndexMixin
1616

1717

@@ -25,7 +25,7 @@ class Chapter(
2525
"""Chapter model."""
2626

2727
objects = models.Manager()
28-
active_chapters = ActiveChaptertManager()
28+
active_chapters = ActiveChapterManager()
2929

3030
class Meta:
3131
db_table = "owasp_chapters"

backend/apps/owasp/models/committee.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""OWASP app commettee model."""
1+
"""OWASP app committee model."""
22

33
from functools import lru_cache
44

backend/apps/owasp/models/managers/chapter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.db.models import Q
55

66

7-
class ActiveChaptertManager(models.Manager):
7+
class ActiveChapterManager(models.Manager):
88
"""Active chapters."""
99

1010
def get_queryset(self):

backend/apps/owasp/models/project.py

-9
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,6 @@ def bulk_save(projects, fields=None):
230230
"""Bulk save projects."""
231231
BulkSaveModel.bulk_save(Project, projects, fields=fields)
232232

233-
@staticmethod
234-
def get_gsoc_projects(year, attributes=None):
235-
"""Return GSoC projects."""
236-
projects = Project.objects.filter(custom_tags__contains=[f"gsoc{year}"])
237-
if attributes:
238-
projects = projects.values(*attributes)
239-
240-
return projects
241-
242233
@staticmethod
243234
def update_data(gh_repository, repository, save=True):
244235
"""Update project data."""

backend/apps/slack/commands/board.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.common.constants import NL
66
from apps.slack.apps import SlackConfig
77
from apps.slack.blocks import markdown
8+
from apps.slack.utils import get_text
89

910
COMMAND = "/board"
1011

@@ -21,7 +22,11 @@ def board_handler(ack, command, client):
2122
]
2223

2324
conversation = client.conversations_open(users=command["user_id"])
24-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
25+
client.chat_postMessage(
26+
blocks=blocks,
27+
channel=conversation["channel"]["id"],
28+
text=get_text(blocks),
29+
)
2530

2631

2732
if SlackConfig.app:

backend/apps/slack/commands/chapters.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from apps.slack.common.constants import COMMAND_HELP, COMMAND_START
99
from apps.slack.common.handlers.chapters import get_blocks
1010
from apps.slack.common.presentation import EntityPresentation
11+
from apps.slack.utils import get_text
1112

1213
COMMAND = "/chapters"
1314

@@ -45,7 +46,11 @@ def chapters_handler(ack, command, client):
4546
)
4647

4748
conversation = client.conversations_open(users=command["user_id"])
48-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
49+
client.chat_postMessage(
50+
channel=conversation["channel"]["id"],
51+
blocks=blocks,
52+
text=get_text(blocks),
53+
)
4954

5055

5156
if SlackConfig.app:

backend/apps/slack/commands/committees.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.slack.apps import SlackConfig
66
from apps.slack.common.handlers.committees import get_blocks
77
from apps.slack.common.presentation import EntityPresentation
8+
from apps.slack.utils import get_text
89

910
COMMAND = "/committees"
1011

@@ -29,7 +30,11 @@ def committees_handler(ack, command, client):
2930
),
3031
)
3132
conversation = client.conversations_open(users=command["user_id"])
32-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
33+
client.chat_postMessage(
34+
blocks=blocks,
35+
channel=conversation["channel"]["id"],
36+
text=get_text(blocks),
37+
)
3338

3439

3540
if SlackConfig.app:

backend/apps/slack/commands/community.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.common.constants import NL
66
from apps.slack.apps import SlackConfig
77
from apps.slack.blocks import markdown
8+
from apps.slack.utils import get_text
89

910
COMMAND = "/community"
1011

@@ -23,7 +24,11 @@ def community_handler(ack, command, client):
2324
]
2425

2526
conversation = client.conversations_open(users=command["user_id"])
26-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
27+
client.chat_postMessage(
28+
blocks=blocks,
29+
channel=conversation["channel"]["id"],
30+
text=get_text(blocks),
31+
)
2732

2833

2934
if SlackConfig.app:

backend/apps/slack/commands/contact.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.common.constants import NL
66
from apps.slack.apps import SlackConfig
77
from apps.slack.blocks import markdown
8+
from apps.slack.utils import get_text
89

910
COMMAND = "/contact"
1011

@@ -21,7 +22,11 @@ def contact_handler(ack, command, client):
2122
]
2223

2324
conversation = client.conversations_open(users=command["user_id"])
24-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
25+
client.chat_postMessage(
26+
blocks=blocks,
27+
channel=conversation["channel"]["id"],
28+
text=get_text(blocks),
29+
)
2530

2631

2732
if SlackConfig.app:

backend/apps/slack/commands/contribute.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from apps.slack.common.constants import COMMAND_HELP, COMMAND_START
99
from apps.slack.common.handlers.contribute import get_blocks
1010
from apps.slack.common.presentation import EntityPresentation
11+
from apps.slack.utils import get_text
1112

1213
COMMAND = "/contribute"
1314

@@ -44,7 +45,11 @@ def contribute_handler(ack, command, client):
4445
)
4546

4647
conversation = client.conversations_open(users=command["user_id"])
47-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
48+
client.chat_postMessage(
49+
channel=conversation["channel"]["id"],
50+
blocks=blocks,
51+
text=get_text(blocks),
52+
)
4853

4954

5055
if SlackConfig.app:

backend/apps/slack/commands/donate.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.common.constants import NL, OWASP_WEBSITE_URL
66
from apps.slack.apps import SlackConfig
77
from apps.slack.blocks import markdown
8+
from apps.slack.utils import get_text
89

910
COMMAND = "/donate"
1011

@@ -39,7 +40,11 @@ def donate_handler(ack, command, client):
3940
]
4041

4142
conversation = client.conversations_open(users=command["user_id"])
42-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
43+
client.chat_postMessage(
44+
blocks=blocks,
45+
channel=conversation["channel"]["id"],
46+
text=get_text(blocks),
47+
)
4348

4449

4550
if SlackConfig.app:

backend/apps/slack/commands/events.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from apps.common.constants import NL
66
from apps.slack.apps import SlackConfig
77
from apps.slack.blocks import markdown
8+
from apps.slack.utils import get_text
89

910
COMMAND = "/events"
1011

@@ -21,7 +22,11 @@ def events_handler(ack, command, client):
2122
]
2223

2324
conversation = client.conversations_open(users=command["user_id"])
24-
client.chat_postMessage(channel=conversation["channel"]["id"], blocks=blocks)
25+
client.chat_postMessage(
26+
blocks=blocks,
27+
channel=conversation["channel"]["id"],
28+
text=get_text(blocks),
29+
)
2530

2631

2732
if SlackConfig.app:

0 commit comments

Comments
 (0)