-
-
Notifications
You must be signed in to change notification settings - Fork 530
frontend for snapshotDetailsPage #981
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
08f0c4e
snapshot extended
arkid15r 2c1bfbf
Merge branch 'OWASP:main' into fix/snapshot-improvement
yashgoyal0110 d7fa0ef
Merge branch 'OWASP:main' into fix/snapshot-improvement
yashgoyal0110 046adb0
Merge branch 'OWASP:main' into fix/snapshot-improvement
yashgoyal0110 44d087f
Merge branch 'OWASP:main' into fix/snapshot-improvement
yashgoyal0110 b31d756
Merge branch 'OWASP:main' into fix/snapshot-improvement
yashgoyal0110 e6eb283
commit
yashgoyal0110 881d5bf
Merge branch 'OWASP:main' into fix/snapshot-improvement
yashgoyal0110 4f1a728
commit
yashgoyal0110 321c138
commit
yashgoyal0110 d711bc5
commit
yashgoyal0110 73bf682
commit
yashgoyal0110 dd4375b
initial frontend for the snapshotdetailspage
abhayymishraa a531300
minor issue
abhayymishraa 6a18d7f
Merge branch 'main' into feat/snapshotDetailsPage
abhayymishraa 7acd9f5
fixed some issue
abhayymishraa 87188f9
backend test fix
abhayymishraa c09ef31
All test-case fix
abhayymishraa 1002e0a
some optimization
abhayymishraa a267966
fixed case
abhayymishraa 6770e46
Merge branch 'main' into pr/abhayymishraa/981
arkid15r 2caa257
Update code
arkid15r 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
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,57 @@ | ||
| """OWASP snapshot GraphQL node.""" | ||
|
|
||
| import graphene | ||
|
|
||
| from apps.github.graphql.nodes.issue import IssueNode | ||
| from apps.github.graphql.nodes.release import ReleaseNode | ||
| from apps.github.graphql.nodes.user import UserNode | ||
| from apps.owasp.graphql.nodes.chapter import ChapterNode | ||
| from apps.owasp.graphql.nodes.common import GenericEntityNode | ||
| from apps.owasp.graphql.nodes.project import ProjectNode | ||
| from apps.owasp.models.snapshot import Snapshot | ||
|
|
||
| RECENT_ISSUES_LIMIT = 100 | ||
|
|
||
|
|
||
| class SnapshotNode(GenericEntityNode): | ||
| """Snapshot node.""" | ||
|
|
||
| key = graphene.String() | ||
| new_chapters = graphene.List(ChapterNode) | ||
| new_issues = graphene.List(IssueNode) | ||
| new_projects = graphene.List(ProjectNode) | ||
| new_releases = graphene.List(ReleaseNode) | ||
| new_users = graphene.List(UserNode) | ||
|
|
||
| class Meta: | ||
| model = Snapshot | ||
| fields = ( | ||
| "created_at", | ||
| "end_at", | ||
| "start_at", | ||
| "title", | ||
| ) | ||
|
|
||
| def resolve_key(self, info): | ||
| """Resolve key.""" | ||
| return self.key | ||
|
|
||
| def resolve_new_chapters(self, info): | ||
| """Resolve new chapters.""" | ||
| return self.new_chapters.all() | ||
|
|
||
| def resolve_new_issues(self, info): | ||
| """Resolve recent new issues.""" | ||
| return self.new_issues.order_by("-created_at")[:RECENT_ISSUES_LIMIT] | ||
|
|
||
| def resolve_new_projects(self, info): | ||
| """Resolve recent new projects.""" | ||
| return self.new_projects.order_by("-created_at") | ||
|
|
||
| def resolve_new_releases(self, info): | ||
| """Resolve recent new releases.""" | ||
| return self.new_releases.order_by("-published_at") | ||
|
|
||
| def resolve_new_users(self, info): | ||
| """Resolve recent new users.""" | ||
| return self.new_users.order_by("-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
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,32 @@ | ||
| """OWASP snapshot GraphQL queries.""" | ||
|
|
||
| import graphene | ||
|
|
||
| from apps.common.graphql.queries import BaseQuery | ||
| from apps.owasp.graphql.nodes.snapshot import SnapshotNode | ||
| from apps.owasp.models.snapshot import Snapshot | ||
|
|
||
|
|
||
| class SnapshotQuery(BaseQuery): | ||
| """Snapshot queries.""" | ||
|
|
||
| snapshot = graphene.Field( | ||
| SnapshotNode, | ||
| key=graphene.String(required=True), | ||
| ) | ||
|
|
||
| recent_snapshots = graphene.List( | ||
| SnapshotNode, | ||
| limit=graphene.Int(default_value=8), | ||
| ) | ||
|
|
||
| def resolve_snapshot(root, info, key): | ||
| """Resolve snapshot by key.""" | ||
| try: | ||
| return Snapshot.objects.get(key=key) | ||
| except Snapshot.DoesNotExist: | ||
| return None | ||
|
|
||
| def resolve_recent_snapshots(root, info, limit): | ||
| """Resolve recent snapshots.""" | ||
| return Snapshot.objects.order_by("-created_at")[:limit] |
23 changes: 23 additions & 0 deletions
23
backend/apps/owasp/migrations/0020_snapshot_key_snapshot_title.py
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,23 @@ | ||
| # Generated by Django 5.1.6 on 2025-03-03 02:18 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("owasp", "0019_alter_event_category"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="snapshot", | ||
| name="key", | ||
| field=models.CharField(default="", max_length=10, unique=True), | ||
| preserve_default=False, | ||
| ), | ||
| migrations.AddField( | ||
| model_name="snapshot", | ||
| name="title", | ||
| field=models.CharField(default="", max_length=255), | ||
| ), | ||
| ] |
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,17 @@ | ||
| # Generated by Django 5.1.6 on 2025-03-03 02:23 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("owasp", "0020_snapshot_key_snapshot_title"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name="snapshot", | ||
| name="key", | ||
| field=models.CharField(blank=True, max_length=10, unique=True), | ||
| ), | ||
| ] |
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
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,87 @@ | ||
| export const mockSnapshotDetailsData = { | ||
| snapshot: { | ||
| title: 'New Snapshot', | ||
| key: '2024-12', | ||
| updatedAt: '2025-03-02T20:33:46.880330+00:00', | ||
| createdAt: '2025-03-01T22:00:34.361937+00:00', | ||
| startAt: '2024-12-01T00:00:00+00:00', | ||
| endAt: '2024-12-31T22:00:30+00:00', | ||
| status: 'completed', | ||
| errorMessage: '', | ||
| newReleases: [ | ||
| { | ||
| name: 'v0.9.2', | ||
| publishedAt: '2024-12-13T14:43:46+00:00', | ||
| tagName: 'v0.9.2', | ||
| projectName: 'test-project-1', | ||
| }, | ||
| { | ||
| name: 'Latest pre-release', | ||
| publishedAt: '2024-12-13T13:17:30+00:00', | ||
| tagName: 'pre-release', | ||
| projectName: 'test-project-2', | ||
| }, | ||
| ], | ||
| newProjects: [ | ||
| { | ||
| key: 'nest', | ||
| name: 'OWASP Nest', | ||
| summary: | ||
| 'OWASP Nest is a code project aimed at improving how OWASP manages its collection of projects...', | ||
| starsCount: 14, | ||
| forksCount: 19, | ||
| contributorsCount: 14, | ||
| level: 'INCUBATOR', | ||
| isActive: true, | ||
| repositoriesCount: 2, | ||
| topContributors: [ | ||
| { | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/2201626?v=4', | ||
| contributionsCount: 170, | ||
| login: 'arkid15r', | ||
| name: 'Arkadii Yakovets', | ||
| }, | ||
| { | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/97700473?v=4', | ||
| contributionsCount: 5, | ||
| login: 'test-user', | ||
| name: 'test user', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| newChapters: [ | ||
| { | ||
| key: 'sivagangai', | ||
| name: 'OWASP Sivagangai', | ||
| createdAt: '2024-07-30T10:07:33+00:00', | ||
| suggestedLocation: 'Sivagangai, Tamil Nadu, India', | ||
| region: 'Asia', | ||
| summary: | ||
| 'OWASP Sivagangai is a new local chapter that focuses on AI and application security...', | ||
| topContributors: [ | ||
| { | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/95969896?v=4', | ||
| contributionsCount: 14, | ||
| login: 'acs-web-tech', | ||
| name: 'P.ARUN', | ||
| }, | ||
| { | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/56408064?v=4', | ||
| contributionsCount: 1, | ||
| login: 'test-user-1', | ||
| name: '', | ||
| }, | ||
| ], | ||
| updatedAt: 1727353371.0, | ||
| url: 'https://owasp.org/www-chapter-sivagangai', | ||
| relatedUrls: [], | ||
| geoLocation: { | ||
| lat: 9.9650599, | ||
| lng: 78.7204283237222, | ||
| }, | ||
| isActive: true, | ||
| }, | ||
| ], | ||
| }, | ||
| } |
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.
🛠️ Refactor suggestion
Consider a more informative str representation
The current implementation returns just the title. If titles are not set, this would result in empty strings being displayed in the admin interface. Consider a more informative string representation that includes fallback information.
def __str__(self): """Return a string representation of the snapshot.""" - return self.title + if self.title: + return self.title + return f"Snapshot {self.key or self.start_at.strftime('%Y-%m-%d')}"📝 Committable suggestion