-
-
Notifications
You must be signed in to change notification settings - Fork 219
Added participants who have expressed interest in a specific issue in issue model . #1995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rajgupta36
wants to merge
21
commits into
OWASP:feature/mentorship-portal
Choose a base branch
from
Rajgupta36:feat/contributor-interested
base: feature/mentorship-portal
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
81a8713
add field in modela and interested-user logic
Rajgupta36 1ee00ae
update code
Rajgupta36 5fd03c7
added models , commands
Rajgupta36 e2b66b7
update suggestion
Rajgupta36 d924096
update sync_comment
Rajgupta36 b77a27c
update code
Rajgupta36 c617cf3
clean
Rajgupta36 bc1d0d6
update models
Rajgupta36 686e6c1
cleanup
Rajgupta36 67290f9
implemented suggestions
Rajgupta36 0610ee8
merge upstream into branch
Rajgupta36 bafd85c
Merge branch 'main' into feat/contributor-interested
kasya a1e176c
update code
Rajgupta36 defe5a8
update migration
Rajgupta36 5f84dcd
update code
Rajgupta36 d3f1576
update models and code
Rajgupta36 de914ed
simplification
Rajgupta36 bd6f76f
fix comment update logic
Rajgupta36 db785cc
update code
Rajgupta36 31b4463
update code
Rajgupta36 85082aa
update code
Rajgupta36 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,21 @@ | ||
"""GitHub app Comment model admin.""" | ||
|
||
from django.contrib import admin | ||
|
||
from apps.github.models import Comment | ||
|
||
|
||
class CommentAdmin(admin.ModelAdmin): | ||
"""Admin for Comment model.""" | ||
|
||
list_display = ( | ||
"body", | ||
"author", | ||
"nest_created_at", | ||
"nest_updated_at", | ||
) | ||
list_filter = ("nest_created_at", "nest_updated_at") | ||
search_fields = ("body", "author__login") | ||
|
||
|
||
admin.site.register(Comment, CommentAdmin) |
This file contains hidden or 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 hidden or 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,61 @@ | ||
# Generated by Django 5.2.5 on 2025-09-24 13:14 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("contenttypes", "0002_remove_content_type_name"), | ||
("github", "0035_alter_user_bio_alter_user_is_owasp_staff"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Comment", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("nest_created_at", models.DateTimeField(auto_now_add=True)), | ||
("nest_updated_at", models.DateTimeField(auto_now=True)), | ||
("github_id", models.BigIntegerField(unique=True, verbose_name="Github ID")), | ||
( | ||
"created_at", | ||
models.DateTimeField(blank=True, null=True, verbose_name="Created at"), | ||
), | ||
( | ||
"updated_at", | ||
models.DateTimeField( | ||
blank=True, db_index=True, null=True, verbose_name="Updated at" | ||
), | ||
), | ||
("body", models.TextField(verbose_name="Body")), | ||
("object_id", models.PositiveIntegerField()), | ||
( | ||
"author", | ||
models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="comments", | ||
to="github.user", | ||
), | ||
), | ||
( | ||
"content_type", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="contenttypes.contenttype" | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "Comment", | ||
"verbose_name_plural": "Comments", | ||
"db_table": "github_comments", | ||
"ordering": ("-nest_created_at",), | ||
}, | ||
), | ||
] |
This file contains hidden or 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 @@ | ||
"""Github app.""" | ||
|
||
from .comment import Comment | ||
from .milestone import Milestone | ||
from .pull_request import PullRequest | ||
from .user import User |
This file contains hidden or 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,85 @@ | ||
"""GitHub app comment model.""" | ||
|
||
from django.contrib.contenttypes.fields import GenericForeignKey | ||
from django.contrib.contenttypes.models import ContentType | ||
from django.db import models | ||
|
||
from apps.common.models import BulkSaveModel, TimestampedModel | ||
from apps.common.utils import truncate | ||
|
||
|
||
class Comment(BulkSaveModel, TimestampedModel): | ||
"""Represents a comment on a GitHub Issue.""" | ||
|
||
class Meta: | ||
db_table = "github_comments" | ||
verbose_name = "Comment" | ||
verbose_name_plural = "Comments" | ||
ordering = ("-nest_created_at",) | ||
|
||
github_id = models.BigIntegerField(unique=True, verbose_name="Github ID") | ||
created_at = models.DateTimeField(verbose_name="Created at", null=True, blank=True) | ||
updated_at = models.DateTimeField( | ||
verbose_name="Updated at", null=True, blank=True, db_index=True | ||
) | ||
author = models.ForeignKey( | ||
"github.User", on_delete=models.SET_NULL, null=True, related_name="comments" | ||
) | ||
body = models.TextField(verbose_name="Body") | ||
|
||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) | ||
object_id = models.PositiveIntegerField() | ||
content_object = GenericForeignKey("content_type", "object_id") | ||
|
||
def __str__(self): | ||
"""Return a string representation of the comment.""" | ||
return f"{self.author} - {truncate(self.body, 50)}" | ||
|
||
def from_github(self, gh_comment, author=None): | ||
"""Populate fields from a GitHub API comment object.""" | ||
field_mapping = { | ||
"body": "body", | ||
"created_at": "created_at", | ||
"updated_at": "updated_at", | ||
} | ||
|
||
for model_field, gh_field in field_mapping.items(): | ||
value = getattr(gh_comment, gh_field, None) | ||
if value is not None: | ||
setattr(self, model_field, value) | ||
|
||
self.author = author | ||
|
||
@staticmethod | ||
def bulk_save(comments, fields=None): # type: ignore[override] | ||
"""Bulk save comments.""" | ||
BulkSaveModel.bulk_save(Comment, comments, fields=fields) | ||
|
||
@staticmethod | ||
def update_data(gh_comment, *, author=None, content_object=None, save: bool = True): | ||
"""Update or create a Comment instance from a GitHub comment object. | ||
|
||
Args: | ||
gh_comment (github.IssueComment.IssueComment): GitHub comment object. | ||
author (User, optional): Comment author. Defaults to None. | ||
content_object (GenericForeignKey, optional): Content object. Defaults to None. | ||
save (bool, optional): Whether to save the instance immediately. Defaults to True. | ||
|
||
Returns: | ||
Comment: The updated or newly created Comment instance. | ||
|
||
""" | ||
try: | ||
comment = Comment.objects.get(github_id=gh_comment.id) | ||
except Comment.DoesNotExist: | ||
comment = Comment(github_id=gh_comment.id) | ||
|
||
comment.from_github(gh_comment, author=author) | ||
|
||
if content_object is not None: | ||
comment.content_object = content_object | ||
|
||
if save: | ||
comment.save() | ||
|
||
return comment |
This file contains hidden or 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 hidden or 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,3 @@ | ||
mentorship-update-comments: | ||
@echo "Syncing Github Comments related to issues" | ||
@CMD="python manage.py mentorship_update_comments" $(MAKE) exec-backend-command |
This file contains hidden or 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 hidden or 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,16 @@ | ||
"""Mentorship app IssueUserInterest admin.""" | ||
|
||
from django.contrib import admin | ||
|
||
from apps.mentorship.models import IssueUserInterest | ||
|
||
|
||
class IssueUserInterestAdmin(admin.ModelAdmin): | ||
"""IssueUserInterest admin.""" | ||
|
||
list_display = ("module", "issue") | ||
search_fields = ("module__name", "user__login", "issue__title") | ||
list_filter = ("module",) | ||
|
||
|
||
admin.site.register(IssueUserInterest, IssueUserInterestAdmin) |
Empty file.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You run the bulk save for each comment/iteration. It doesn't make sense 🤷♂️