Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeeejeets committed Mar 18, 2020
0 parents commit dddec36
Show file tree
Hide file tree
Showing 48 changed files with 1,299 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
venv/
.vscode
Binary file added FakeCheker/__pycache__/settings.cpython-38.pyc
Binary file not shown.
Binary file added FakeCheker/__pycache__/urls.cpython-38.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions FakeCheker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Django>=2
django-extensions
djangorestframework
122 changes: 122 additions & 0 deletions FakeCheker/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""
Django settings for FakeCheker project.
Generated by 'django-admin startproject' using Django 2.1.7.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^l)7d*%h&db4uft@dk%h-w&nup#pu%)a!d)c7jwgoixo5_hm0$'

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'fake-checker',
]

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',
]

ROOT_URLCONF = 'FakeCheker.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'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 = 'FakeCheker.wsgi.application'


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

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

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


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'
2 changes: 2 additions & 0 deletions FakeCheker/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
pytest-django
24 changes: 24 additions & 0 deletions FakeCheker/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""newproject URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
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 django.views.generic import TemplateView

urlpatterns = [
path('', TemplateView.as_view(template_name='index.html'), name='index'),
path('fake-checker/', include('fake-checker.urls')),
path('admin/', admin.site.urls),
]
16 changes: 16 additions & 0 deletions FakeCheker/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for newproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'FakeCheker.settings')

application = get_wsgi_application()
Empty file added fake-checker/__init__.py
Empty file.
Binary file added fake-checker/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added fake-checker/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file added fake-checker/__pycache__/api.cpython-38.pyc
Binary file not shown.
Binary file added fake-checker/__pycache__/forms.cpython-38.pyc
Binary file not shown.
Binary file added fake-checker/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file added fake-checker/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file added fake-checker/__pycache__/views.cpython-38.pyc
Binary file not shown.
106 changes: 106 additions & 0 deletions fake-checker/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from django.contrib import admin
from django import forms

from . import models


class ReviewAdminForm(forms.ModelForm):

class Meta:
model = models.Review
fields = "__all__"


class ReviewAdmin(admin.ModelAdmin):
form = ReviewAdminForm
list_display = [
"last_updated",
"created",
]
readonly_fields = [
"last_updated",
"created",
]


class CategoryAdminForm(forms.ModelForm):

class Meta:
model = models.Category
fields = "__all__"


class CategoryAdmin(admin.ModelAdmin):
form = CategoryAdminForm
list_display = [
"created",
"last_updated",
]
readonly_fields = [
"created",
"last_updated",
]


class QuestionAdminForm(forms.ModelForm):

class Meta:
model = models.Question
fields = "__all__"


class QuestionAdmin(admin.ModelAdmin):
form = QuestionAdminForm
list_display = [
"created",
"last_updated",
]
readonly_fields = [
"created",
"last_updated",
]


class ExpertAdminForm(forms.ModelForm):

class Meta:
model = models.Expert
fields = "__all__"


class ExpertAdmin(admin.ModelAdmin):
form = ExpertAdminForm
list_display = [
"last_updated",
"created",
]
readonly_fields = [
"last_updated",
"created",
]


class RedactorAdminForm(forms.ModelForm):

class Meta:
model = models.Redactor
fields = "__all__"


class RedactorAdmin(admin.ModelAdmin):
form = RedactorAdminForm
list_display = [
"last_updated",
"created",
]
readonly_fields = [
"last_updated",
"created",
]


admin.site.register(models.Review, ReviewAdmin)
admin.site.register(models.Category, CategoryAdmin)
admin.site.register(models.Question, QuestionAdmin)
admin.site.register(models.Expert, ExpertAdmin)
admin.site.register(models.Redactor, RedactorAdmin)
44 changes: 44 additions & 0 deletions fake-checker/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from rest_framework import viewsets, permissions

from . import serializers
from . import models


class ReviewViewSet(viewsets.ModelViewSet):
"""ViewSet for the Review class"""

queryset = models.Review.objects.all()
serializer_class = serializers.ReviewSerializer
permission_classes = [permissions.IsAuthenticated]


class CategoryViewSet(viewsets.ModelViewSet):
"""ViewSet for the Category class"""

queryset = models.Category.objects.all()
serializer_class = serializers.CategorySerializer
permission_classes = [permissions.IsAuthenticated]


class QuestionViewSet(viewsets.ModelViewSet):
"""ViewSet for the Question class"""

queryset = models.Question.objects.all()
serializer_class = serializers.QuestionSerializer
permission_classes = [permissions.IsAuthenticated]


class ExpertViewSet(viewsets.ModelViewSet):
"""ViewSet for the Expert class"""

queryset = models.Expert.objects.all()
serializer_class = serializers.ExpertSerializer
permission_classes = [permissions.IsAuthenticated]


class RedactorViewSet(viewsets.ModelViewSet):
"""ViewSet for the Redactor class"""

queryset = models.Redactor.objects.all()
serializer_class = serializers.RedactorSerializer
permission_classes = [permissions.IsAuthenticated]
44 changes: 44 additions & 0 deletions fake-checker/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from django import forms
from . import models


class ReviewForm(forms.ModelForm):
class Meta:
model = models.Review
fields = [
"question",
"expert",
]


class CategoryForm(forms.ModelForm):
class Meta:
model = models.Category
fields = [
"questions",
"expert",
]


class QuestionForm(forms.ModelForm):
class Meta:
model = models.Question
fields = [
"category",
"redactor",
]


class ExpertForm(forms.ModelForm):
class Meta:
model = models.Expert
fields = [
"category",
]


class RedactorForm(forms.ModelForm):
class Meta:
model = models.Redactor
fields = []

Loading

0 comments on commit dddec36

Please sign in to comment.