Skip to content

Commit 06ec001

Browse files
committed
Add jquery
Add basic implementation for vote view Add create comment form , review status form Add review list page , review-list view Add login , logout functionality 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 Add support for webfinger Add pytest run doctests Edit Actor model , Edit create_git_repo and view function Try to make Reputation model more general Add bulma static folders Add create git function Add basic UI, security_team_profile, database_admin_profile Remove the extra relations ( many-to-many ,..) and use JSONField instead Add test for following and follower actors Edit basic django model Add support for pytest, black, isort Add django model test Add missing fields in GitRepo Add basic Implementation for ER diagram Initial config for purl-sync project Signed-off-by: ziadhany <ziadhany2016@gmail.com>
1 parent ea0b934 commit 06ec001

66 files changed

Lines changed: 22235 additions & 0 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ Pipfile
103103
*.bak
104104
/.cache/
105105
/tmp/
106+
/purl_sync/venv_purl/

purl_sync/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "purl_sync.settings")
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == "__main__":
22+
main()
455 Bytes
Loading

purl_sync/purl_sync/__init__.py

Whitespace-only changes.

purl_sync/purl_sync/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for purl_sync project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "purl_sync.settings")
15+
16+
application = get_asgi_application()

purl_sync/purl_sync/settings.py

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import os
2+
from pathlib import Path
3+
4+
import environ
5+
6+
PROJECT_DIR = Path(__file__).resolve().parent
7+
ROOT_DIR = PROJECT_DIR.parent
8+
# Environment
9+
10+
ENV_FILE = "/etc/purl_sync/.env"
11+
if not Path(ENV_FILE).exists():
12+
ENV_FILE = ROOT_DIR / ".env"
13+
14+
env = environ.Env()
15+
environ.Env.read_env(str(ENV_FILE))
16+
17+
DOMAIN = env.str("DOMAIN", "127.0.0.1")
18+
PUBLIC_KEY = env.str("PUBLIC_KEY")
19+
20+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
21+
BASE_DIR = Path(__file__).resolve().parent.parent
22+
23+
# Quick-start development settings - unsuitable for production
24+
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
25+
26+
# SECURITY WARNING: keep the secret key used in production secret!
27+
SECRET_KEY = "django-insecure-uoc-dv7+6%dy7c6(hc$6*z_m-#4y*jp1%-^*5)y&+i9-@j7zup"
28+
29+
# SECURITY WARNING: don't run with debug turned on in production!
30+
DEBUG = True
31+
32+
ALLOWED_HOSTS = []
33+
34+
# Application definition
35+
36+
INSTALLED_APPS = [
37+
"django.contrib.admin",
38+
"django.contrib.auth",
39+
"django.contrib.contenttypes",
40+
"django.contrib.sessions",
41+
"django.contrib.messages",
42+
"django.contrib.staticfiles",
43+
"review",
44+
"oauth2_provider",
45+
]
46+
47+
MIDDLEWARE = [
48+
"django.middleware.security.SecurityMiddleware",
49+
"django.contrib.sessions.middleware.SessionMiddleware",
50+
"django.middleware.common.CommonMiddleware",
51+
"django.middleware.csrf.CsrfViewMiddleware",
52+
"django.contrib.auth.middleware.AuthenticationMiddleware",
53+
"django.contrib.messages.middleware.MessageMiddleware",
54+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
55+
]
56+
57+
ROOT_URLCONF = "purl_sync.urls"
58+
59+
TEMPLATES = [
60+
{
61+
"BACKEND": "django.template.backends.django.DjangoTemplates",
62+
"DIRS": [],
63+
"APP_DIRS": True,
64+
"OPTIONS": {
65+
"context_processors": [
66+
"django.template.context_processors.debug",
67+
"django.template.context_processors.request",
68+
"django.contrib.auth.context_processors.auth",
69+
"django.contrib.messages.context_processors.messages",
70+
],
71+
},
72+
},
73+
]
74+
75+
WSGI_APPLICATION = "purl_sync.wsgi.application"
76+
77+
# Database
78+
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
79+
80+
81+
# DATABASES = {
82+
# "default": {
83+
# "ENGINE": env.str("PURL_SYNC_DB_ENGINE", "django.db.backends.postgresql"),
84+
# "HOST": env.str("PURL_SYNC_DB_HOST", "localhost"),
85+
# "NAME": env.str("PURL_SYNC_DB_NAME", "purl-sync"),
86+
# "USER": env.str("PURL_SYNC_DB_USER", "vulnerablecode"),
87+
# "PASSWORD": env.str("PURL_SYNC_DB_PASSWORD", "vulnerablecode"),
88+
# "PORT": env.str("PURL_SYNC_DB_PORT", "5432"),
89+
# }
90+
# }
91+
92+
DATABASES = {
93+
"default": {
94+
"ENGINE": "django.db.backends.sqlite3",
95+
"NAME": "mydatabase.db",
96+
}
97+
}
98+
99+
# Password validation
100+
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
101+
102+
AUTH_PASSWORD_VALIDATORS = [
103+
{
104+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
105+
},
106+
{
107+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
108+
},
109+
{
110+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
111+
},
112+
{
113+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
114+
},
115+
]
116+
117+
REST_FRAMEWORK = {
118+
"DEFAULT_AUTHENTICATION_CLASSES": [
119+
"oauth2_provider.contrib.rest_framework.OAuth2Authentication",
120+
]
121+
}
122+
123+
# Internationalization
124+
# https://docs.djangoproject.com/en/4.1/topics/i18n/
125+
126+
LANGUAGE_CODE = "en-us"
127+
128+
TIME_ZONE = "UTC"
129+
130+
USE_I18N = True
131+
132+
USE_TZ = True
133+
134+
# Static files (CSS, JavaScript, Images)
135+
# https://docs.djangoproject.com/en/4.1/howto/static-files/
136+
137+
STATIC_URL = "static/"
138+
139+
# Default primary key field type
140+
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
141+
142+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
143+
144+
MEDIA_URL = "/media/"
145+
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
146+
GIT_PATH = os.path.join(MEDIA_ROOT, "git")
147+
ACTIVITYPUB_CONTENT_TYPE = "application/activity+json"

purl_sync/purl_sync/urls.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""purl_sync URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/4.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.conf import settings
17+
from django.conf.urls.static import static
18+
from django.contrib import admin
19+
from django.contrib.auth.views import LogoutView
20+
from django.urls import include
21+
from django.urls import path
22+
23+
from review.views import CreatGitView
24+
from review.views import DatabaseAdminView
25+
from review.views import GitRepoListView
26+
from review.views import ReviewListView
27+
from review.views import ReviewView
28+
from review.views import SecurityTeamInbox
29+
from review.views import SecurityTeamOutbox
30+
from review.views import SecurityTeamSignUp
31+
from review.views import SecurityTeamView
32+
from review.views import UserLogin
33+
from review.views import WebfingerView
34+
from review.views import create_review
35+
from review.views import database_admin_inbox
36+
from review.views import database_admin_outbox
37+
from review.views import note_vote
38+
from review.views import review_vote
39+
40+
urlpatterns = [
41+
path("admin/", admin.site.urls),
42+
path(".well-known/webfinger", WebfingerView.as_view(), name="web-finger"),
43+
path("security-team/@<str:slug>", SecurityTeamView.as_view(), name="security-team-profile"),
44+
path("database-admin/@<str:slug>", DatabaseAdminView.as_view(), name="database-admin-profile"),
45+
path("accounts/sign-up", SecurityTeamSignUp.as_view(), name="signup"),
46+
path("accounts/login", UserLogin.as_view(), name="login"),
47+
path("accounts/logout", LogoutView.as_view(next_page="login"), name="logout"),
48+
path("create-repo", CreatGitView.as_view(), name="repo-create"),
49+
path("create-review", create_review),
50+
path("review/<uuid:id>/", ReviewView.as_view(), name="review-page"),
51+
path("review-list", ReviewListView.as_view()),
52+
path("repo-list", GitRepoListView.as_view()),
53+
path("review/<uuid:review_id>/votes/", review_vote, name="vote-review"),
54+
path("note/<uuid:note_id>/votes/", note_vote, name="vote-note"),
55+
path("security-team/<str:username>/inbox/", SecurityTeamInbox.as_view()),
56+
path("security-team/<str:username>/outbox/", SecurityTeamOutbox.as_view()),
57+
path("database-admin/<str:username>/outbox/", database_admin_outbox),
58+
path("database-admin/<str:username>/inbox/", database_admin_inbox),
59+
# path("security-team/@<str:username>/edit-followers/", database_admin_profile_view),
60+
# path("database-admin/<str:username>/followers/", ),
61+
# path("security-team/<str:username>/following/", ),
62+
path("o/", include("oauth2_provider.urls", namespace="oauth2_provider")),
63+
]
64+
65+
if settings.DEBUG:
66+
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

purl_sync/purl_sync/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for purl_sync project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "purl_sync.settings")
15+
16+
application = get_wsgi_application()

purl_sync/pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
6+
[tool.pytest.ini_options]
7+
DJANGO_SETTINGS_MODULE = "purl_sync.settings"
8+
python_files = "*.py"
9+
python_classes = "Test"
10+
python_functions = "test"
11+
addopts = "--doctest-modules"
12+
13+
[tool.black]
14+
line-length = 100
15+
include = '\.pyi?$'
16+
skip_gitignore = true
17+
# 'extend-exclude' excludes files or directories in addition to the defaults
18+
extend-exclude = '''
19+
(
20+
^/venv/.*
21+
| ^/purl_sync/migrations/.*
22+
)
23+
'''
24+
25+
26+
[tool.isort]
27+
profile = "black"
28+
line_length = 100
29+
force_single_line = true
30+
skip_gitignore = true
31+
skip_glob = "purl_sync/migrations/*"

purl_sync/requirements.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
asgiref==3.7.2
2+
Django==4.2.2
3+
django-environ==0.10.0
4+
exceptiongroup==1.1.1
5+
iniconfig==2.0.0
6+
packaging==23.1
7+
Pillow==9.5.0
8+
pluggy==1.0.0
9+
pytest==7.3.2
10+
pytest-django==4.5.2
11+
sqlparse==0.4.4
12+
tomli==2.0.1
13+
typing_extensions==4.6.3

0 commit comments

Comments
 (0)