Skip to content

Commit

Permalink
Add login , logout functionality
Browse files Browse the repository at this point in the history
Add a basic ui for review , review list , create review pages
Edit model.py ( use a many-to-many relationship instead of json field )

Add test

Signed-off-by: ziad <[email protected]>
  • Loading branch information
ziadhany committed Jul 3, 2023
1 parent 49d8c5f commit 736b49a
Show file tree
Hide file tree
Showing 19 changed files with 1,235 additions and 306 deletions.
1 change: 1 addition & 0 deletions purl_sync/purl_sync/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"review",
"oauth2_provider",
]

MIDDLEWARE = [
Expand Down
43 changes: 29 additions & 14 deletions purl_sync/purl_sync/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,44 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth.views import LogoutView
from django.urls import include
from django.urls import path

from review.views import CreatGitView
from review.views import DatabaseAdminView
from review.views import ReviewListView
from review.views import SecurityTeamSignUp
from review.views import SecurityTeamView
from review.views import UserLogin
from review.views import WebfingerView
from review.views import database_admin_profile_view
from review.views import login_view
from review.views import security_team_profile_view
from review.views import security_team_signup_view
from review.views import create_review
from review.views import database_admin_inbox
from review.views import database_admin_outbox
from review.views import review_page_view
from review.views import security_team_inbox
from review.views import security_team_outbox

urlpatterns = [
path("admin/", admin.site.urls),
path(".well-known/webfinger", WebfingerView.as_view()),
path("security-team/@<str:username>", security_team_profile_view),
path("database-admin/@<str:username>", database_admin_profile_view),
path("login/", login_view),
path("signup/", security_team_signup_view),
# path("create-repo/", CreatGitView.as_view()),
# path("review/<id>/", review_page_view),
path("security-team/@<str:slug>", SecurityTeamView.as_view()),
path("database-admin/@<str:slug>", DatabaseAdminView.as_view()),
path("sign-up/", SecurityTeamSignUp.as_view(), name="signup"),
path("login/", UserLogin.as_view(), name="login"),
path("logout/", LogoutView.as_view(next_page="login"), name="logout"),
# path("create-repo", CreatGitView.as_view()),
path("review/<id>/", review_page_view),
path("create-review", create_review),
path("review-list", ReviewListView.as_view()),
path("security-team/<str:username>/inbox/", security_team_inbox),
path("security-team/<str:username>/outbox/", security_team_outbox),
path("database-admin/<str:username>/outbox/", database_admin_outbox),
path("database-admin/<str:username>/inbox/", database_admin_inbox),
# path("security-team/@<str:username>/edit-followers/", database_admin_profile_view),
# path("<str:username>/inbox/", ),
# path("<str:username>/outbox/", ),
# path("<str:username>/followers/", ),
# path("<str:username>/following/", ),
# path("database-admin/<str:username>/followers/", ),
# path("security-team/<str:username>/following/", ),
path("o/", include("oauth2_provider.urls", namespace="oauth2_provider")),
]

if settings.DEBUG:
Expand Down
2 changes: 2 additions & 0 deletions purl_sync/review/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin

from review.models import DatabaseAdmin
from review.models import Follow
from review.models import GitRepo
from review.models import Notes
from review.models import PackageUrl
Expand All @@ -21,6 +22,7 @@
admin.site.register(PackageUrl)
admin.site.register(Notes)
admin.site.register(Review)
admin.site.register(Follow)

admin.site.register(RemoteSecurityTeam)
admin.site.register(RemoteDatabaseAdmin)
15 changes: 15 additions & 0 deletions purl_sync/review/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User


class CreateRepoForm(forms.Form):
repo_name = forms.CharField()
repo_url = forms.URLField(required=True)


class SecurityTeamSignUpForm(UserCreationForm):
email = forms.EmailField(max_length=254)

class Meta:
model = User
fields = (
"username",
"email",
"password1",
"password2",
)
102 changes: 76 additions & 26 deletions purl_sync/review/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Generated by Django 4.2.2 on 2023-06-29 08:43
# Generated by Django 4.2.2 on 2023-07-03 13:56

import uuid

import django.db.models.deletion
from django.conf import settings
from django.db import migrations
from django.db import models
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):
Expand Down Expand Up @@ -37,18 +35,8 @@ class Migration(migrations.Migration):
("note", models.CharField(help_text="the profile description", max_length=100)),
("public_key", models.TextField()),
(
"followers",
models.JSONField(
default=dict,
help_text="e.g. {'secrityteam@vcio': ['pkg:npm/[email protected]']}",
),
),
("followers_count", models.PositiveIntegerField(default=0)),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
"database_type",
models.IntegerField(choices=[(0, "Local"), (1, "Remote")], default=1),
),
],
options={
Expand Down Expand Up @@ -112,8 +100,13 @@ class Migration(migrations.Migration):
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("voter_acct", models.CharField(help_text="[email protected]", max_length=100)),
("gainer_acct", models.CharField(help_text="[email protected]", max_length=100)),
("voter", models.CharField(help_text="[email protected]", max_length=100)),
("acceptor", models.CharField(help_text="[email protected]", max_length=100)),
("object_url", models.URLField()),
(
"object_type",
models.IntegerField(choices=[(0, "Review"), (1, "Comment")], default=0),
),
("positive", models.BooleanField(default=True)),
],
),
Expand Down Expand Up @@ -157,16 +150,24 @@ class Migration(migrations.Migration):
("note", models.CharField(help_text="the profile description", max_length=100)),
("public_key", models.TextField()),
(
"following",
models.JSONField(
default=dict, help_text="e.g. {'datebase1@vcio': ['pkg:npm/[email protected]']}"
"security_team_type",
models.IntegerField(choices=[(0, "Local"), (1, "Remote")], default=1),
),
(
"remote_actor",
models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="review.remotesecurityteam",
),
),
("following_count", models.PositiveIntegerField(default=0)),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
Expand All @@ -188,7 +189,7 @@ class Migration(migrations.Migration):
(
"status",
models.IntegerField(
choices=[(1, "Open"), (2, "Draft"), (3, "Closed"), (4, "Merged")]
choices=[(0, "Open"), (1, "Draft"), (2, "Closed"), (3, "Merged")]
),
),
(
Expand Down Expand Up @@ -219,4 +220,53 @@ class Migration(migrations.Migration):
),
],
),
migrations.AddField(
model_name="databaseadmin",
name="remote_actor",
field=models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="review.remotedatabaseadmin",
),
),
migrations.AddField(
model_name="databaseadmin",
name="user",
field=models.OneToOneField(
null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
migrations.CreateModel(
name="Follow",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"database_admin",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="review.databaseadmin"
),
),
(
"purl",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="review.packageurl"
),
),
(
"security_team",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="review.securityteam"
),
),
],
options={
"unique_together": {("purl", "database_admin", "security_team")},
},
),
]
Loading

0 comments on commit 736b49a

Please sign in to comment.