Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3849e79
Database switched from sqlite3 to postgresql
RustamHabibovv May 3, 2024
3509a3c
Pylint issues
RustamHabibovv May 3, 2024
6139f18
Pylint and mypy issues solving
RustamHabibovv May 8, 2024
01a1a46
Pylint settings file issue solving
RustamHabibovv May 8, 2024
9b65869
Pylint version change
RustamHabibovv May 8, 2024
1f5df96
Pylint version downgrade
RustamHabibovv May 8, 2024
83cc6e5
Pylint skip settings file
RustamHabibovv May 8, 2024
a93ed5c
Pylint fail fast
RustamHabibovv May 8, 2024
c3c59f3
Back to initial state
RustamHabibovv May 8, 2024
736ece8
Pylint.yml file changed
RustamHabibovv May 8, 2024
5950580
Disable import error
RustamHabibovv May 8, 2024
0e892b3
Disable E0001
RustamHabibovv May 8, 2024
948c831
Django settings module configured
RustamHabibovv May 8, 2024
353fd00
Disable E5110
RustamHabibovv May 8, 2024
4b702c8
Update README.md
RustamHabibovv May 8, 2024
5829652
Disable errors only for settings file
RustamHabibovv May 9, 2024
46ec901
Merge branch 'master' of github.com:Strexas/qr_web into RHA/QRW-117
RustamHabibovv May 9, 2024
2e86ba5
Merge branch 'RHA/QRW-117' of github.com:Strexas/qr_web into RHA/QRW-117
RustamHabibovv May 9, 2024
c3806a7
E5110 solving
RustamHabibovv May 9, 2024
05a0c26
Pylint changes
RustamHabibovv May 9, 2024
e6a949d
Pylint
RustamHabibovv May 9, 2024
5a8efcd
Pylint solving
RustamHabibovv May 9, 2024
08adb4e
Solving pylint E5110
RustamHabibovv May 9, 2024
61cd4ff
pylint django-configure
RustamHabibovv May 16, 2024
7aa1772
Pylint django configure
RustamHabibovv May 16, 2024
92a465f
Setting enviroment variable
RustamHabibovv May 16, 2024
da92f54
Configure secret key
RustamHabibovv May 16, 2024
c6ec40f
Added enviroment variables
RustamHabibovv May 16, 2024
ac3721b
Update README.md
RustamHabibovv May 16, 2024
5e2e9b5
Added author image to view page
RustamHabibovv May 22, 2024
bc63b42
Static code analysis file updates
RustamHabibovv May 26, 2024
adafa4c
Requirements update
RustamHabibovv May 26, 2024
c0b06d3
Adding module docstring to static_code_analysis file
RustamHabibovv May 26, 2024
48a78ac
Merge branch 'RHA/QRW-117' of github.com:Strexas/qr_web into RHA/QRW-153
RustamHabibovv May 26, 2024
13be250
Pull changes
RustamHabibovv May 26, 2024
e4c57d2
Delete image file
RustamHabibovv May 26, 2024
2966807
add module string
RustamHabibovv May 26, 2024
4eb4da0
Gitignore changes
RustamHabibovv May 26, 2024
1d6ef80
Resolving conflicts
RustamHabibovv May 26, 2024
2e45523
Resolving conflicts
RustamHabibovv May 26, 2024
1eddb55
Changing requirements file
RustamHabibovv May 26, 2024
72524d5
Settings file pylint fixes
RustamHabibovv May 26, 2024
3e32877
Mypy changes
RustamHabibovv May 26, 2024
4d12c37
Solve conflicts
RustamHabibovv May 26, 2024
e8e1d89
Add final line
RustamHabibovv May 26, 2024
3582c2b
remove spec symbol
May 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pipo
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint
pip install pylint-django
- name: Analysing the code with pylint
- name: Load environment variables from .env
run: |
pylint -j 0\
--load-plugins=pylint_django \
--max-parents='14' \
--django-settings-module=qr_web.settings \
$(git ls-files '*.py')
if [ -f .env ]; then
export $(cat .env | grep -v ^# | xargs)
fi
- name: Set Django settings module
run: echo "DJANGO_SETTINGS_MODULE=qr_web.settings" >> $GITHUB_ENV
- name: Analysing the code with pylint (all files except settings.py)
run: |
pylint -j 0 \
--load-plugins=pylint_django \
--django-settings-module=qr_web.settings \
--max-parents='14' \
--ignore=venv \
$(git ls-files '*.py')
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ Make migrations:
Migrate:

`python manage.py migrate`

## Setup Local Database
1.)Download Postgresql according to your operating system:https://www.postgresql.org/download/

2.)Open pgAdmin4( it will be automatically included when you download postgresql)

3.)Click Server and right click Databases, create new Database

4.)For keeping sensitive information about database, create .env file in your repository.

5.) Your .env file should look like this:
`SECRET_KEY=django-insecure-728k0bs%91o$^sp%aa_ji@2fmtwpdk7r1na#*$%l2+%)7tnpo3
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432`

6.) Make migrations and migrate, your local postgresql database is ready.
## Run
`python manage.py runserver`

Expand Down
23 changes: 13 additions & 10 deletions constructor/templates/constructor/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,30 @@
<div class="container bg-light shadow-md p-5 form-layout">
<br>
{% load editorjs %}
<div class="title">
{{ post.title}}
</div>
Created by: {{ post.user}}
<div class="title">
{{ post.title }}
</div>
<br>
<div class ="viewform">
<br>
<div class ="testform">
{{ post.content | editorjs}}
Created by: {{ post.user.username }}
<img class = "ts-circle__sm" src="{{ post.user.profile.image.url }}" alt="{{ post.user.username }}'s Profile Image"
>
<br>
<div class="viewform">
<br>
<div class="testform">
{{ post.content | editorjs }}
<br>
</div>
</div>
<br>
<br>
{% if user.is_authenticated %}
{% if request.user == post.user %}
<a href="{% url 'page_edit' page_id=post.upid %}" class="btn btn-primary w-100 btn-block p-2">Edit page</a>
<br>
<br>
{% endif %}
<a href="{% url 'profile' %}" class="btn btn-secondary w-100 btn-block p-2">Back to profile</a>
{% endif %}
</div>
</body>
{%endblock%}
{% endblock %}
1 change: 1 addition & 0 deletions constructor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ def get(self, request, page_id):
"""
# pylint: disable=no-member
page = Page.objects.get(upid=page_id)

return render(request, 'constructor/view.html', {'post': page})
6 changes: 6 additions & 0 deletions qr_web/.env
Comment thread
RustamHabibovv marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SECRET_KEY=django-insecure-728k0bs%91o$^sp%aa_ji@2fmtwpdk7r1na#*$%l2+%)7tnpo3
DB_NAME=qrweb_db
DB_USER=postgres
DB_PASSWORD=killer04
DB_HOST=127.0.0.1
DB_PORT=5432
29 changes: 17 additions & 12 deletions qr_web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@
import os.path
from pathlib import Path
import mimetypes
from google.oauth2 import service_account
import environ # type: ignore[import-untyped]

from google.oauth2 import service_account # type: ignore[import-untyped]



mimetypes.add_type("text/css", ".css", True)


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent



# Quick-start development settings - unsuitable for production
# 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-69mez*=oxw)h+a60&8-15kxz&xh%dh@&6k^mt&zre^g507aqt_'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = 'RENDER' not in os.environ
Expand Down Expand Up @@ -63,7 +62,6 @@
GS_BUCKET_NAME = 'qr_web_image_bucket'
GS_DEFAULT_ACL = 'publicRead'


# Application definition

INSTALLED_APPS = [
Expand Down Expand Up @@ -118,14 +116,21 @@

WSGI_APPLICATION = 'qr_web.wsgi.application'


# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
env = environ.Env()
environ.Env.read_env()

SECRET_KEY = env("SECRET_KEY")

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': env("DB_NAME"),
'USER': env("DB_USER"),
'PASSWORD': env("DB_PASSWORD"),
'HOST': env("DB_HOST"),
'PORT': env("DB_PORT"),
}
}
LOGGING = {
Expand All @@ -144,7 +149,7 @@
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'django_editorjs_fields.log',
'maxBytes': 1024*1024*5, # 5 MB
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 5,
'formatter': 'standard',
},
Expand Down Expand Up @@ -179,7 +184,6 @@
'social_core.backends.google.GoogleOAuth2',
]


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

Expand All @@ -191,7 +195,6 @@

USE_TZ = True


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

Expand All @@ -218,3 +221,5 @@
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = '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'

EDITORJS_VERSION = '2.27.0'
EDITORJS_IMAGE_UPLOAD_PATH = MEDIA_ROOT + '/constructor/'
EDITORJS_IMAGE_UPLOAD_PATH_DATE = '%Y/%m/%d/%I_%M_%S'
Binary file modified requirements.txt
Binary file not shown.
16 changes: 8 additions & 8 deletions static_code_analysis.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Runs mypy and pylint"""

"""File to run static code analysis for mypy and pylint"""
import subprocess

# MyPy
subprocess.run("mypy --install-types --non-interactive".split(), check=True)
subprocess.run("mypy ./".split(), check=False)
subprocess.run("mypy ./ --exclude venv".split(), check=False)

# PyLint
subprocess.run("pylint -j 0\
--load-plugins=pylint_django \
--max-parents=14 \
--django-settings-module=qr_web.settings "
subprocess.run("pylint -j 0 "
"--load-plugins=pylint_django "
"--max-parents=14 "
"--django-settings-module=qr_web.settings "
"--recursive=y "
"--ignore=.venv ./".split(), check=False)
"--ignore=venv "
"./".split(), check=False)