├── backend
├── api
│ ├── __init__.py
│ ├── tests.py
│ ├── apps.py
│ ├── validators.py
│ ├── admin.py
│ ├── urls.py
│ ├── serializers.py
│ ├── permissions.py
│ ├── views.py
│ └── models.py
├── backend
│ ├── __init__.py
│ ├── asgi.py
│ ├── wsgi.py
│ ├── urls.py
│ └── settings.py
└── manage.py
├── .vscode
└── settings.json
├── todo.txt
├── frontend
├── public
│ ├── robots.txt
│ ├── favicon.ico
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── index.html
├── src
│ ├── setupTests.js
│ ├── App.test.js
│ ├── index.css
│ ├── reportWebVitals.js
│ ├── index.js
│ ├── App.js
│ ├── App.css
│ └── logo.svg
├── package.json
└── README.md
├── .idea
├── vcs.xml
├── misc.xml
├── .gitignore
├── inspectionProfiles
│ └── profiles_settings.xml
├── modules.xml
├── dataSources.xml
└── Blogify.iml
└── .gitignore
/backend/api/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/backend/backend/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.pythonPath": ".venv/bin/python"
3 | }
4 |
--------------------------------------------------------------------------------
/backend/api/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/todo.txt:
--------------------------------------------------------------------------------
1 | backend:
2 | more models
3 | writting tests
4 | user model
--------------------------------------------------------------------------------
/frontend/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/frontend/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amir-Mohamad/Blogify/HEAD/frontend/public/favicon.ico
--------------------------------------------------------------------------------
/frontend/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amir-Mohamad/Blogify/HEAD/frontend/public/logo192.png
--------------------------------------------------------------------------------
/frontend/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Amir-Mohamad/Blogify/HEAD/frontend/public/logo512.png
--------------------------------------------------------------------------------
/backend/api/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class ApiConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'api'
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/frontend/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/frontend/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/backend/api/validators.py:
--------------------------------------------------------------------------------
1 | from django.core.files.images import get_image_dimensions
2 | from django.conf import settings
3 |
4 |
5 | def validate_image(value):
6 | size = get_image_dimensions(value)
7 | if size > settings.MAX_UPLOAD_ADMIN_SIZE:
8 | raise ValueError("Please keep file size under 2 MB")
--------------------------------------------------------------------------------
/frontend/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/frontend/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/backend/api/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Article, Category
3 |
4 |
5 | @admin.register(Article)
6 | class ArticleAdmin(admin.ModelAdmin):
7 | list_display = ('title', 'updated', 'cover')
8 | list_filter = ('created', 'updated')
9 | prepopulated_fields = {'slug': ('title',)}
10 |
11 |
12 | @admin.register(Category)
13 | class CategoryAdmin(admin.ModelAdmin):
14 | prepopulated_fields = {'slug': ('title',)}
15 |
--------------------------------------------------------------------------------
/backend/backend/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for backend 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/3.2/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', 'backend.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/backend/backend/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for backend 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/3.2/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', 'backend.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/backend/api/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path, include
2 | from rest_framework.routers import DefaultRouter
3 | from . import views
4 |
5 |
6 | router = DefaultRouter()
7 | router.register(r'articles_list', views.ArticleViewSet, basename='articles_list')
8 | router.register(r'category_list', views.CategoryViewSet, basename="category_list")
9 |
10 |
11 |
12 | urlpatterns = [
13 | path('', views.EndPointsAPI.as_view(), name="endpoints"),
14 | # path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
15 | path('', include(router.urls)),
16 | ]
--------------------------------------------------------------------------------
/.idea/dataSources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | sqlite.xerial
6 | true
7 | org.sqlite.JDBC
8 | jdbc:sqlite:$PROJECT_DIR$/backend/db.sqlite3
9 | $ProjectFileDir$
10 |
11 |
12 |
--------------------------------------------------------------------------------
/frontend/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import reportWebVitals from './reportWebVitals';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want to start measuring performance in your app, pass a function
15 | // to log results (for example: reportWebVitals(console.log))
16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 | reportWebVitals();
18 |
--------------------------------------------------------------------------------
/frontend/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/frontend/src/App.js:
--------------------------------------------------------------------------------
1 | import logo from './logo.svg';
2 | import './App.css';
3 |
4 | function App() {
5 | return (
6 |
22 | );
23 | }
24 |
25 | export default App;
26 |
--------------------------------------------------------------------------------
/backend/backend/urls.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.urls import path, include
3 | from django.conf import settings
4 | from django.conf.urls.static import static
5 | from dj_rest_auth.views import PasswordResetConfirmView
6 |
7 | urlpatterns = [
8 | path('admin/', admin.site.urls),
9 | # Api app
10 | path('api/', include('api.urls')),
11 | path('api/rest-auth/', include('dj_rest_auth.urls')),
12 | path('api/rest-auth/registration/', include('dj_rest_auth.registration.urls')),
13 | path('api/rest-auth/password/reset/confirm///', PasswordResetConfirmView.as_view(), name="password_reset_confirm"),
14 |
15 | ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
--------------------------------------------------------------------------------
/frontend/src/App.css:
--------------------------------------------------------------------------------
1 | .App {
2 | text-align: center;
3 | }
4 |
5 | .App-logo {
6 | height: 40vmin;
7 | pointer-events: none;
8 | }
9 |
10 | @media (prefers-reduced-motion: no-preference) {
11 | .App-logo {
12 | animation: App-logo-spin infinite 20s linear;
13 | }
14 | }
15 |
16 | .App-header {
17 | background-color: #282c34;
18 | min-height: 100vh;
19 | display: flex;
20 | flex-direction: column;
21 | align-items: center;
22 | justify-content: center;
23 | font-size: calc(10px + 2vmin);
24 | color: white;
25 | }
26 |
27 | .App-link {
28 | color: #61dafb;
29 | }
30 |
31 | @keyframes App-logo-spin {
32 | from {
33 | transform: rotate(0deg);
34 | }
35 | to {
36 | transform: rotate(360deg);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/backend/manage.py:
--------------------------------------------------------------------------------
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', 'backend.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()
23 |
--------------------------------------------------------------------------------
/.idea/Blogify.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/backend/api/serializers.py:
--------------------------------------------------------------------------------
1 | from rest_framework import serializers
2 | from .models import Article, Category
3 | from drf_dynamic_fields import DynamicFieldsMixin
4 |
5 |
6 | class ArticleSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
7 | def get_author(self, obj):
8 | return {
9 | "username": obj.author.username,
10 | "first_name": obj.author.first_name,
11 | "last_name": obj.author.last_name,
12 | }
13 |
14 | def get_category(self, obj):
15 | return {
16 | "title": obj.category.title,
17 | }
18 |
19 | author = serializers.SerializerMethodField("get_author")
20 | category = serializers.SerializerMethodField("get_category")
21 |
22 | class Meta:
23 | model = Article
24 | fields = '__all__'
25 |
26 |
27 | class CategorySerializer(DynamicFieldsMixin, serializers.ModelSerializer):
28 | class Meta:
29 | model = Category
30 | fields = '__all__'
31 |
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.11.4",
7 | "@testing-library/react": "^11.1.0",
8 | "@testing-library/user-event": "^12.1.10",
9 | "react": "^17.0.2",
10 | "react-dom": "^17.0.2",
11 | "react-scripts": "4.0.3",
12 | "web-vitals": "^1.0.1"
13 | },
14 | "scripts": {
15 | "start": "react-scripts start",
16 | "build": "react-scripts build",
17 | "test": "react-scripts test",
18 | "eject": "react-scripts eject"
19 | },
20 | "eslintConfig": {
21 | "extends": [
22 | "react-app",
23 | "react-app/jest"
24 | ]
25 | },
26 | "browserslist": {
27 | "production": [
28 | ">0.2%",
29 | "not dead",
30 | "not op_mini all"
31 | ],
32 | "development": [
33 | "last 1 chrome version",
34 | "last 1 firefox version",
35 | "last 1 safari version"
36 | ]
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/backend/api/permissions.py:
--------------------------------------------------------------------------------
1 | from rest_framework.permissions import BasePermission, SAFE_METHODS
2 |
3 |
4 | class IsSuperUser(BasePermission):
5 | def has_permission(self, request, view):
6 | return bool(request.user and request.user.is_superuser)
7 |
8 |
9 | class IsStaffOrReadOnly(BasePermission):
10 | def has_permission(self, request, view):
11 | return bool(
12 | request.method in SAFE_METHODS or
13 | request.user and
14 | request.user.is_staff
15 | )
16 |
17 |
18 | class IsSuperUserOrStaffReadOnly(BasePermission):
19 | def has_permission(self, request, view):
20 | return bool(
21 | # get access to authors readonly
22 | request.method in SAFE_METHODS and
23 | request.user and
24 | request.user.is_staff or
25 | # get access to superuser full
26 | request.user and
27 | request.user.is_superuser
28 | )
29 |
30 |
31 | class IsAuthorOrReadOnly(BasePermission):
32 | def has_object_permission(self, request, view, obj):
33 | if request.method in SAFE_METHODS:
34 | return True
35 |
36 | return bool(
37 | # get access to superuser
38 | request.user.is_authenticated and
39 | request.user.is_superuser or
40 | # get access to author of object
41 | obj.author == request.user
42 | )
43 |
44 |
--------------------------------------------------------------------------------
/backend/api/views.py:
--------------------------------------------------------------------------------
1 | from rest_framework.response import Response
2 | from rest_framework.views import APIView
3 | from rest_framework import viewsets
4 | from rest_framework import status
5 | # permission
6 | from rest_framework.permissions import IsAuthenticated
7 | from .serializers import ArticleSerializer, CategorySerializer
8 | from .models import Article, Category
9 |
10 |
11 | class EndPointsAPI(APIView):
12 | """
13 | Showing all the endpoinsts in project
14 | """
15 |
16 | def get(self, request):
17 | endpoints = [
18 | '127.0.0.1:8000/api/',
19 | '127.0.0.1:8000/api/article_list',
20 | '127.0.0.1:8000/api/rest-auth',
21 | 'api/rest-auth/password/reset/',
22 | 'api/rest-auth/password/reset/confirm/',
23 | 'api/rest-auth/login/',
24 | 'api/rest-auth/logout/',
25 | 'api/rest-auth/user/',
26 | 'api/rest-auth/password/change/',
27 | 'api/rest-auth/token/verify/',
28 | 'api/rest-auth/token/refresh/',
29 | 'api/rest-auth/registration/',
30 | 'api/rest-auth/password/reset/confirm/',
31 | ]
32 | return Response(endpoints, status=status.HTTP_200_OK)
33 |
34 |
35 | class ArticleViewSet(viewsets.ModelViewSet):
36 | queryset = Article.objects.all()
37 | serializer_class = ArticleSerializer
38 | permission_classes = [IsAuthenticated,]
39 |
40 |
41 | class CategoryViewSet(viewsets.ModelViewSet):
42 | queryset = Category.objects.filter(is_active=True)
43 | serializer_class = CategorySerializer
44 | permission_classes = [IsAuthenticated,]
--------------------------------------------------------------------------------
/frontend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/backend/api/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth import get_user_model
3 | from django.utils.html import format_html
4 | from ckeditor.fields import RichTextField
5 | from .validators import validate_image
6 |
7 |
8 | User = get_user_model()
9 |
10 |
11 | class Category(models.Model):
12 | """
13 | All the articles have category,
14 | with OneToMany RelationShip
15 | """
16 | title = models.CharField(max_length=100)
17 | slug = models.SlugField(unique=True)
18 | is_active = models.BooleanField(default=True, null=True)
19 |
20 | class Meta:
21 | verbose_name = 'Category'
22 | verbose_name_plural = 'Categories'
23 |
24 | def __str__(self):
25 | return f'{self.title} created'
26 |
27 |
28 | class Article(models.Model):
29 | """
30 | The main article model
31 | """
32 | STATUS_CHOICES = (
33 | ('d', 'draft'),
34 | ('p', "publish"),
35 | )
36 | author = models.ForeignKey(User, on_delete=models.DO_NOTHING)
37 | category = models.ForeignKey(Category, on_delete=models.DO_NOTHING)
38 | title = models.CharField(max_length=100)
39 | slug = models.SlugField(unique=True)
40 | description = RichTextField()
41 | image = models.ImageField(upload_to='images/', validators=[validate_image])
42 | created = models.DateTimeField(auto_now_add=True)
43 | updated = models.DateTimeField(auto_now=True)
44 | is_active = models.BooleanField(default=True, null=True)
45 |
46 | def __str__(self):
47 | return f'Article {self.title} created at {self.created}'
48 |
49 | # for showing the article image
50 | def cover(self):
51 | if self.image:
52 | return format_html("
".format(self.image.url))
53 | return "nothing"
54 | cover.short_description = "cover"
55 |
56 | def likes_count(self):
57 | return self.a_like.count()
58 |
59 | def user_can_like(self, user):
60 | user_like = user.u_like.all()
61 | qs = user_like.filter(post=self)
62 | if qs.exists():
63 | return True
64 | return False
65 |
66 |
67 | class Like(models.Model):
68 | user = models.ForeignKey(User, on_delete=models.DO_NOTHING, related_name="u_like")
69 | article = models.ForeignKey(Article, on_delete=models.DO_NOTHING, related_name="a_like")
70 |
71 | def __str__(self):
72 | return f'{self.user} likes {self.article}'
73 |
--------------------------------------------------------------------------------
/frontend/src/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 | # dependencies
3 | frontend/node_modules
4 | /node_modules
5 | frontend/.pnp
6 | frontend/.pnp.js
7 |
8 | # testing
9 | frontend/coverage
10 |
11 | # production
12 | frontend/build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
25 |
26 | # Python
27 | # Byte-compiled / optimized / DLL files
28 | __pycache__/
29 | *.py[cod]
30 | *$py.class
31 |
32 | # C extensions
33 | *.so
34 |
35 | # Distribution / packaging
36 | .Python
37 | build/
38 | develop-eggs/
39 | dist/
40 | downloads/
41 | eggs/
42 | .eggs/
43 | lib/
44 | lib64/
45 | parts/
46 | sdist/
47 | var/
48 | wheels/
49 | share/python-wheels/
50 | *.egg-info/
51 | .installed.cfg
52 | *.egg
53 | MANIFEST
54 |
55 | # PyInstaller
56 | # Usually these files are written by a python script from a template
57 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
58 | *.manifest
59 | *.spec
60 |
61 | # Installer logs
62 | pip-log.txt
63 | pip-delete-this-directory.txt
64 |
65 | # Unit test / coverage reports
66 | htmlcov/
67 | .tox/
68 | .nox/
69 | .coverage
70 | .coverage.*
71 | .cache
72 | nosetests.xml
73 | coverage.xml
74 | *.cover
75 | *.py,cover
76 | .hypothesis/
77 | .pytest_cache/
78 | cover/
79 |
80 | # Translations
81 | *.mo
82 | *.pot
83 |
84 | # Django stuff:
85 | *.log
86 | local_settings.py
87 | db.sqlite3
88 | db.sqlite3-journal
89 |
90 | # Flask stuff:
91 | instance/
92 | .webassets-cache
93 |
94 | # Scrapy stuff:
95 | .scrapy
96 |
97 | # Sphinx documentation
98 | docs/_build/
99 |
100 | # PyBuilder
101 | .pybuilder/
102 | target/
103 |
104 | # Jupyter Notebook
105 | .ipynb_checkpoints
106 |
107 | # IPython
108 | profile_default/
109 | ipython_config.py
110 |
111 | # pyenv
112 | # For a library or package, you might want to ignore these files since the code is
113 | # intended to run in multiple environments; otherwise, check them in:
114 | # .python-version
115 |
116 | # pipenv
117 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
118 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
119 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
120 | # install all needed dependencies.
121 | #Pipfile.lock
122 |
123 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
124 | __pypackages__/
125 |
126 | # Celery stuff
127 | celerybeat-schedule
128 | celerybeat.pid
129 |
130 | # SageMath parsed files
131 | *.sage.py
132 |
133 | # Environments
134 | .env
135 | backend/.venv
136 | env/
137 | .venv/
138 | ENV/
139 | env.bak/
140 | venv.bak/
141 |
142 | # Spyder project settings
143 | .spyderproject
144 | .spyproject
145 |
146 | # Rope project settings
147 | .ropeproject
148 |
149 | # mkdocs documentation
150 | /site
151 |
152 | # mypy
153 | .mypy_cache/
154 | .dmypy.json
155 | dmypy.json
156 |
157 | # Pyre type checker
158 | .pyre/
159 |
160 | # pytype static type analyzer
161 | .pytype/
162 |
163 | # Cython debug symbols
164 | cython_debug/
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `yarn start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `yarn test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `yarn build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `yarn eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39 |
40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `yarn build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/backend/backend/settings.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | import os
3 |
4 | BASE_DIR = Path(__file__).resolve().parent.parent
5 |
6 | SECRET_KEY = 'django-insecure-8b-k5rw#3^3r(4ohf6nbzjxu!v%0ri3c+q07i)04dbl39yo+n&'
7 | DEBUG = True
8 | ALLOWED_HOSTS = []
9 |
10 | # Application definition
11 |
12 | INSTALLED_APPS = [
13 | 'django.contrib.sites',
14 | 'django.contrib.admin',
15 | 'django.contrib.auth',
16 | 'django.contrib.contenttypes',
17 | 'django.contrib.sessions',
18 | 'django.contrib.messages',
19 | 'django.contrib.staticfiles',
20 |
21 | # Local apps
22 | 'api.apps.ApiConfig',
23 |
24 | # Third Party apps
25 | 'rest_framework',
26 | 'rest_framework.authtoken',
27 | 'dj_rest_auth',
28 | 'allauth',
29 | 'allauth.account',
30 | 'allauth.socialaccount',
31 | 'dj_rest_auth.registration',
32 | 'corsheaders',
33 | 'ckeditor',
34 | ]
35 |
36 | SITE_ID = 1
37 |
38 | MIDDLEWARE = [
39 | 'corsheaders.middleware.CorsMiddleware',
40 | 'django.middleware.security.SecurityMiddleware',
41 | 'django.contrib.sessions.middleware.SessionMiddleware',
42 | 'django.middleware.common.CommonMiddleware',
43 | 'django.middleware.csrf.CsrfViewMiddleware',
44 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
45 | 'django.contrib.messages.middleware.MessageMiddleware',
46 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
47 | ]
48 |
49 | ROOT_URLCONF = 'backend.urls'
50 |
51 | TEMPLATES = [
52 | {
53 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
54 | 'DIRS': [],
55 | 'APP_DIRS': True,
56 | 'OPTIONS': {
57 | 'context_processors': [
58 | 'django.template.context_processors.debug',
59 | 'django.template.context_processors.request',
60 | 'django.contrib.auth.context_processors.auth',
61 | 'django.contrib.messages.context_processors.messages',
62 | ],
63 | },
64 | },
65 | ]
66 |
67 | WSGI_APPLICATION = 'backend.wsgi.application'
68 |
69 | DATABASES = {
70 | 'default': {
71 | 'ENGINE': 'django.db.backends.sqlite3',
72 | 'NAME': BASE_DIR / 'db.sqlite3',
73 | }
74 | }
75 |
76 | AUTH_PASSWORD_VALIDATORS = [
77 | {
78 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
79 | },
80 | {
81 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
82 | },
83 | {
84 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
85 | },
86 | {
87 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
88 | },
89 | ]
90 |
91 | LANGUAGE_CODE = 'en-us'
92 |
93 | TIME_ZONE = 'UTC'
94 |
95 | USE_I18N = True
96 |
97 | USE_L10N = True
98 |
99 | USE_TZ = True
100 |
101 | STATIC_URL = '/static/'
102 |
103 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
104 | CORS_ALLOW_ALL_ORIGINS = True
105 |
106 | REST_FRAMEWORK = {
107 | 'DEFAULT_PERMISSION_CLASSES': [
108 | 'rest_framework.permissions.IsAuthenticated',
109 | ],
110 | 'DEFAULT_AUTHENTICATION_CLASSES': [
111 | 'dj_rest_auth.jwt_auth.JWTCookieAuthentication',
112 | ]
113 | }
114 |
115 | # Custom
116 | MAX_UPLOAD_ADMIN_SIZE = 2097152 # 2 MB (2000000)
117 |
118 | MEDIA_ROOT = os.path.join(BASE_DIR, "media")
119 | MEDIA_URL = "/media/"
120 |
121 | REST_USE_JWT = True
122 |
123 | JWT_AUTH_COOKIE = 'access'
124 | JWT_AUTH_REFRESH_COOKIE = 'refresh'
125 |
126 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
127 |
128 | # WARNING: Theres a bug in dj-rest-auth that raises "template_name() ...... " error,
129 | # while sending the email for accepting the following link in email
130 |
--------------------------------------------------------------------------------