Skip to content

Commit

Permalink
Merge pull request #454 from bounswe/develop
Browse files Browse the repository at this point in the history
[test] feat(web): add wiki data suggestions
  • Loading branch information
umitcan07 authored May 17, 2024
2 parents fa323dc + ba1ef69 commit b21c068
Show file tree
Hide file tree
Showing 44 changed files with 3,998 additions and 2,715 deletions.
174 changes: 88 additions & 86 deletions backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import os
from dotenv import load_dotenv

load_dotenv('./.env')
load_dotenv("./.env")

from pathlib import Path

from pathlib import Path

Expand All @@ -25,122 +27,122 @@
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-a9)04(qc(hozedr0+a(-g-ujg%*^5exk#=1c=v$vs7!-kb(m+p'
SECRET_KEY = "django-insecure-a9)04(qc(hozedr0+a(-g-ujg%*^5exk#=1c=v$vs7!-kb(m+p"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['164.90.189.150', '159.65.125.158', 'localhost', '127.0.0.1']
ALLOWED_HOSTS = ["164.90.189.150", "159.65.125.158", "localhost", "127.0.0.1"]


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'core',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"corsheaders",
"core",
"drf_yasg",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

CORS_ALLOWED_ORIGINS = [
"http://localhost:5173",
"http://localhost:5174",
"http://localhost:5175",
"https://localhost:5173",
"https://localhost:5174",
"https://localhost:5175",
"http://127.0.0.1:5173",
"http://127.0.0.1:5174",
"http://127.0.0.1:5175",
"https://127.0.0.1:5173",
"https://127.0.0.1:5174",
"https://127.0.0.1:5175",
"http://164.90.189.150:5173",
"http://164.90.189.150:5174",
"http://164.90.189.150:5175",
"https://164.90.189.150:5173",
"https://164.90.189.150:5174",
"https://164.90.189.150:5175",
]
CORS_ALLOW_ALL_ORIGINS = True

# CORS_ALLOWED_ORIGINS = [
# "http://localhost:5173",
# "http://localhost:5174",
# "http://localhost:5175",
# "https://localhost:5173",
# "https://localhost:5174",
# "https://localhost:5175",
# "http://127.0.0.1:5173",
# "http://127.0.0.1:5174",
# "http://127.0.0.1:5175",
# "https://127.0.0.1:5173",
# "https://127.0.0.1:5174",
# "https://127.0.0.1:5175",
# "http://164.90.189.150:5173",
# "http://164.90.189.150:5174",
# "http://164.90.189.150:5175",
# "https://164.90.189.150:5173",
# "https://164.90.189.150:5174",
# "https://164.90.189.150:5175",
# ]

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework_simplejwt.authentication.JWTAuthentication",
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
}

from datetime import timedelta

SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(days=1),
'REFRESH_TOKEN_LIFETIME': timedelta(days=7),
'ROTATE_REFRESH_TOKENS': False,
'BLACKLIST_AFTER_ROTATION': True,
'UPDATE_LAST_LOGIN': False,
'ALGORITHM': 'HS256',
'VERIFYING_KEY': None,
'AUDIENCE': None,
'ISSUER': None,
'AUTH_HEADER_TYPES': ('Bearer',),
'USER_ID_FIELD': 'id',
'USER_ID_CLAIM': 'user_id',
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
'TOKEN_TYPE_CLAIM': 'token_type',
'JTI_CLAIM': 'jti',
"ACCESS_TOKEN_LIFETIME": timedelta(days=1),
"REFRESH_TOKEN_LIFETIME": timedelta(days=7),
"ROTATE_REFRESH_TOKENS": False,
"BLACKLIST_AFTER_ROTATION": True,
"UPDATE_LAST_LOGIN": False,
"ALGORITHM": "HS256",
"VERIFYING_KEY": None,
"AUDIENCE": None,
"ISSUER": None,
"AUTH_HEADER_TYPES": ("Bearer",),
"USER_ID_FIELD": "id",
"USER_ID_CLAIM": "user_id",
"AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
"TOKEN_TYPE_CLAIM": "token_type",
"JTI_CLAIM": "jti",
}

ROOT_URLCONF = 'config.urls'
ROOT_URLCONF = "config.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'config.wsgi.application'
WSGI_APPLICATION = "config.wsgi.application"


# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('MYSQL_USER'),
'PASSWORD': os.getenv('MYSQL_PASSWORD'),
'HOST': os.getenv('DB_HOST'), # Or your MySQL server's IP address
'PORT': os.getenv('DB_PORT'), # Default MySQL port
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.getenv("DB_NAME"),
"USER": os.getenv("MYSQL_USER"),
"PASSWORD": os.getenv("MYSQL_PASSWORD"),
"HOST": os.getenv("DB_HOST"), # Or your MySQL server's IP address
"PORT": os.getenv("DB_PORT"), # Default MySQL port
}
}

Expand All @@ -150,26 +152,26 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -179,9 +181,9 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'static/'
STATIC_URL = "static/"

# Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
9 changes: 5 additions & 4 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include
from rest_framework_simplejwt.views import (
Expand All @@ -22,8 +23,8 @@
)

urlpatterns = [
path('admin/', admin.site.urls),
path('api/v2/', include('core.urls')),
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path("admin/", admin.site.urls),
path("api/v2/", include("core.urls")),
path("api/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
]
4 changes: 2 additions & 2 deletions backend/core/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
GROUP BY ?enemy ?enemyLabel
ORDER BY DESC(?sitelinks)
"""
#occupation query gets an input occupation and output the characters with this occupation.
# occupation query gets an input occupation and output the characters with this occupation.
occupation = """
SELECT DISTINCT ?item ?itemLabel (SUM(?sitelink) AS ?sitelinks)
WHERE {
Expand Down Expand Up @@ -117,4 +117,4 @@
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
"""
"""
8 changes: 5 additions & 3 deletions backend/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
)

router = DefaultRouter()
router.register(r'profiles', ProfileViewSet)
router.register(r"profiles", ProfileViewSet)
router.register(r"posts", PostViewSet)
router.register(r"likes", LikeViewSet)
router.register(r"bookmarks", BookmarkViewSet)
router.register(r'follows', FollowViewSet)
router.register(r"follows", FollowViewSet)
router.register(r"users", UserViewSet)

urlpatterns = [
Expand All @@ -39,5 +39,7 @@
),
path("login/", LoginView.as_view(), name="login"),
path("info/", WikiInfoView.as_view(), name="info"),
path("user-profile/<str:username>/", UserProfileView.as_view(), name="user-profile"),
path(
"user-profile/<str:username>/", UserProfileView.as_view(), name="user-profile"
),
]
Binary file modified backend/requirements.txt
Binary file not shown.
15 changes: 15 additions & 0 deletions bruno/Get followers.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: Get followers
type: http
seq: 8
}

get {
url: {{base_url}}:{{port}}/api/v2/follows/1
body: json
auth: bearer
}

auth:bearer {
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzE1OTc3NjI0LCJpYXQiOjE3MTU4OTEyMjQsImp0aSI6IjgxYjFmODUzNDhiNTQ2MDNhYzQwZWI5OGZhYTM0MjU3IiwidXNlcl9pZCI6MX0.uRZ7LZ2xOflP0p3JEW4705CqAbstjy-LPMQV7Vv_Nnc
}
15 changes: 15 additions & 0 deletions bruno/posts.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: posts
type: http
seq: 11
}

get {
url: {{base_url}}:{{port}}/api/v2/posts
body: none
auth: bearer
}

auth:bearer {
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzE2MDE2NTM1LCJpYXQiOjE3MTU5MzAxMzUsImp0aSI6IjJlZTA5ODhhZjBmMTQxYmI4NzQ3YWE1MDc0Y2M0M2Q4IiwidXNlcl9pZCI6Mn0.yqmsm0OlChj61xuASjLs_jKjI9VDcnx7M5ROq2ln-lQ
}
27 changes: 27 additions & 0 deletions bruno/profile.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
meta {
name: profile
type: http
seq: 10
}

post {
url: {{base_url}}:{{port}}/api/v2/profiles/
body: json
auth: bearer
}

headers {
Content-Type: application/json
}

auth:bearer {
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzE1OTc3ODc3LCJpYXQiOjE3MTU4OTE0NzcsImp0aSI6Ijg0NTEwZWE3MTk2MzQ0NTM5ZmIyOGZmOWY0ZThkZmE3IiwidXNlcl9pZCI6NH0.SFuvZ3CGaKjq8MHTw6EtJXn67GmI5VyDZGYrMeNBsfM
}

body:json {
{
"picture": "emre",
"biography": "kilic"
}

}
11 changes: 11 additions & 0 deletions bruno/swagger.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
meta {
name: swagger
type: http
seq: 5
}

get {
url: {{base_url}}:{{port}}/api/v1/swagger/
body: none
auth: none
}
Loading

0 comments on commit b21c068

Please sign in to comment.