From c03566f0150498c75a147cd6bf8c6582b733a79f Mon Sep 17 00:00:00 2001 From: Mandel Dashboard Date: Sun, 22 Feb 2026 02:35:35 +0100 Subject: [PATCH] initial commit --- .gitignore | 28 ++++++ Jenkinsfile | 83 ++++++++++++++++++ MANIFEST.in | 3 + Makefile | 59 +++++++++++++ README.rst | 85 +++++++++++++++++++ phase2a_test_20260222013532/__init__.py | 0 phase2a_test_20260222013532/main.py | 9 ++ phase2a_test_20260222013532/ocyan.json | 60 +++++++++++++ .../settings/__init__.py | 0 phase2a_test_20260222013532/settings/base.py | 36 ++++++++ .../settings/env/__init__.py | 0 .../settings/env/dev.py | 21 +++++ .../settings/env/prd.py | 15 ++++ .../settings/env/stg.py | 16 ++++ .../phase2a_test_20260222013532/css/.gitkeep | 0 .../img/.gitignore | 0 .../phase2a_test_20260222013532/js/.gitignore | 0 .../phase2a_test_20260222013532/.gitignore | 0 phase2a_test_20260222013532/wsgi.py | 1 + pylintrc | 12 +++ pyproject.toml | 30 +++++++ setup.py | 42 +++++++++ uwsgi-dev.ini | 28 ++++++ 23 files changed, 528 insertions(+) create mode 100644 .gitignore create mode 100644 Jenkinsfile create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.rst create mode 100644 phase2a_test_20260222013532/__init__.py create mode 100644 phase2a_test_20260222013532/main.py create mode 100644 phase2a_test_20260222013532/ocyan.json create mode 100644 phase2a_test_20260222013532/settings/__init__.py create mode 100644 phase2a_test_20260222013532/settings/base.py create mode 100644 phase2a_test_20260222013532/settings/env/__init__.py create mode 100644 phase2a_test_20260222013532/settings/env/dev.py create mode 100644 phase2a_test_20260222013532/settings/env/prd.py create mode 100644 phase2a_test_20260222013532/settings/env/stg.py create mode 100644 phase2a_test_20260222013532/static/phase2a_test_20260222013532/css/.gitkeep create mode 100644 phase2a_test_20260222013532/static/phase2a_test_20260222013532/img/.gitignore create mode 100644 phase2a_test_20260222013532/static/phase2a_test_20260222013532/js/.gitignore create mode 100644 phase2a_test_20260222013532/templates/phase2a_test_20260222013532/.gitignore create mode 100644 phase2a_test_20260222013532/wsgi.py create mode 100644 pylintrc create mode 100644 pyproject.toml create mode 100644 setup.py create mode 100644 uwsgi-dev.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..416ecf8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +.mypy_cache/ +.pytest_cache/ +.vscode/ +__pycache__/ +*.py[ocd] +db.sqlite3 +develop-eggs +bin +parts +sources +.installed.cfg +.mr.developer.cfg +*.egg-info +eggs/ +/static/* +/documents/ +/media +!/media/image_not_found.jpg +dist/ +build/ +lib +pip-selfcheck.json +pyvenv.cfg +.DS_Store +.coverage +coverage.xml +htmlcov/ +venv/ \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..9e68a14 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,83 @@ +#!/usr/bin/env groovy + +pipeline { + agent any + options { disableConcurrentBuilds() } + environment { + PYENVPIPELINE_VIRTUALENV = '1' + } + + stages { + stage('Build') { + steps { + sh ''' + python3 -m venv .venv + . .venv/bin/activate + pip install coverage + pip install --upgrade pip "setuptools==69.5.1" wheel + make EXTRAS="" install + cp "${JOB_BASE_NAME}/ocyan.json" "${JOB_BASE_NAME}/${JOB_BASE_NAME}.json" + pip install pylint pylint-django vdt.versionplugin.wheel + pip install --upgrade "setuptools==69.5.1" wheel + make migrate loaddata collectstatic + pip install "httpx<0.28" + ''' + } + } + stage('Lint') { + steps { + sh ''' + . .venv/bin/activate + pip install coverage + make lint + ''' + } + } + stage('Test') { + steps { + sh ''' + . .venv/bin/activate + pip install coverage + make test + ''' + } + post { + always { + junit allowEmptyResults: true, testResults: '**/nosetests.xml' + } + success { + echo "Coverage step skipped" + } + } + } + } + post { + always { + echo 'This will always run' + } + success { + echo 'This will run only if successful' + sh ''' + . .venv/bin/activate + pip install coverage + ''' + build job: 'deploy-project-stg', + parameters: [string(name: 'PROJECT_NAME', value: env.JOB_BASE_NAME)], + wait: false, + propagate: false + } + failure { + emailext subject: "JENKINS-NOTIFICATION: ${currentBuild.currentResult}: Job '${env.JOB_NAME} #${env.BUILD_NUMBER}'", + body: '${SCRIPT, template="groovy-text.template"}', + recipientProviders: [culprits(), brokenBuildSuspects(), brokenTestsSuspects()] + + } + unstable { + echo 'This will run only if the run was marked as unstable' + } + changed { + echo 'This will run only if the state of the Pipeline has changed' + echo 'For example, if the Pipeline was previously failing but is now successful' + } + } +} diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..32cf251 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +graft phase2a_test_20260222013532 +global-exclude *.py[co] +global-exclude __pycache__ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d82ba09 --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +.PHONY: fail-if-no-virtualenv all install loaddata test lint black debug undebug + +all: install migrate loaddata collectstatic + +fail-if-no-virtualenv: +ifndef VIRTUAL_ENV # check for a virtualenv in development environment +ifndef PYENVPIPELINE_VIRTUALENV # check for jenkins pipeline virtualenv +$(error this makefile needs a virtualenv) +endif +endif + +ifndef PIP_INDEX_URL +PIP_INDEX_URL=https://pypi.mandelblog.com/mandel/testing/+simple/ +endif + +ifndef EXTRAS +EXTRAS="[test]" +endif + +install: fail-if-no-virtualenv + PIP_INDEX_URL=${PIP_INDEX_URL} pip install --pre --editable .${EXTRAS} setuptools wheel --upgrade --upgrade-strategy=eager --use-deprecated=legacy-resolver + +migrate: + manage.py migrate --no-input + +loaddata: + -manage.py loaddemodata + +collectstatic: + manage.py collectstatic --no-input --verbosity=0 + +lint: fail-if-no-virtualenv + cat phase2a_test_20260222013532/ocyan.json |python3 -m json.tool 1>/dev/null + pylint setup.py phase2a_test_20260222013532/ + +black: + @echo "No formatter configured in template; add your preferred formatter here." + +test: fail-if-no-virtualenv + @coverage run --source='phase2a_test_20260222013532' `which manage.py` test + @coverage report + @coverage xml + @coverage html + +run: fail-if-no-virtualenv lint test migrate collectstatic + manage.py runserver + +debug: fail-if-no-virtualenv + PIP_INDEX_URL=${PIP_INDEX_URL} pip install --pre ocyan.plugin.debug + +undebug: + PIP_INDEX_URL=${PIP_INDEX_URL} pip uninstall -y ocyan.plugin.debug + +live: + @echo "Did you update the version in setup.py? [y/N]" && read ans && [ $$ans = y ] + rm -fr dist + rm -fr build* + version --plugin=wheel --skip-tag + devpi --index=projects/production upload dist/* diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..240695f --- /dev/null +++ b/README.rst @@ -0,0 +1,85 @@ +Project phase2a_test_20260222013532 +=================================== + +About phase2a_test_20260222013532 +--------------------------------- +Ocyan project: phase2a_test_20260222013532 + +Installation +------------ +Create a virtualenv, you only need to do this once for each project:: + + mkvirtualenv phase2a_test_20260222013532 + +Next build the project, by installing dependencies and creating the database:: + + make + +Running +------- +Activate the virtualenv:: + + workon phase2a_test_20260222013532 + +You can see which virtualenv is activated, because your +terminal will be prefixed with (phase2a_test_20260222013532). + +Next start the development server:: + + make run + +Testing +------- +Testing is done with the default Django testing capabilities. Check the 'Testing in Django' chapter in Django documentation for details. + +To run the tests, issue the following command:: + + make test + +Linting +------- +Source code is formatted using the `black`[1] formatter in its default settings. Installing format-on-save support for your editor is highly recommended. +`Pylint`[2] is used for source code analysis. +All utilities are installed via the test extra. This extra is installed by default when using the Makefile. + +The following command check style and syntax:: + + make lint + + +1. black: https://pypi.org/project/black/ +2. pylint: https://pypi.org/project/pylint/ + +Edit template translation +------------------------- +The translation in templates + +Activate the virtualenv:: + + workon phase2a_test_20260222013532 + +Create the locale directory in the root of the project:: + + mkdir phase2a_test_20260222013532/locale + +Go in the project_name directory:: + + cd phase2a_test_20260222013532/ + +Run this command to create a file with all translatable strings in the project (note: this is only for the dutch translations):: + + manage.py makemessages -l nl + +Go to your text editor and go in this file:: + + phase2a_test_20260222013532/phase2a_test_20260222013532/locale/nl/LC_MESSAGES/django.po + +This file will have all of the translations some will be correct and dont need to be chanced + +Edit all the translations u want to change +Delete all of the translation u dont want to chance +save file + +Apply the translations:: + + manage.py compilemessages \ No newline at end of file diff --git a/phase2a_test_20260222013532/__init__.py b/phase2a_test_20260222013532/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/main.py b/phase2a_test_20260222013532/main.py new file mode 100644 index 0000000..3758f86 --- /dev/null +++ b/phase2a_test_20260222013532/main.py @@ -0,0 +1,9 @@ +import os +import sys + + +def main(): + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "phase2a_test_20260222013532.settings.base") + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/phase2a_test_20260222013532/ocyan.json b/phase2a_test_20260222013532/ocyan.json new file mode 100644 index 0000000..7267428 --- /dev/null +++ b/phase2a_test_20260222013532/ocyan.json @@ -0,0 +1,60 @@ +{ + "ocyan_plugins": [ + "ocyan.plugin.contact_form", + "ocyan.plugin.cookie_jar", + "ocyan.plugin.demo_data", + "ocyan.plugin.django", + "ocyan.plugin.roadrunner_bs5", + "ocyan.plugin.sentry_logging", + "oxyan.themes", + "ocyan.plugin.varnish", + "ocyan.plugin.wagtail", + "ocyan.plugin.wagtail_blog", + "ocyan.plugin.wagtail_content_page", + "ocyan.plugin.barebone" + ], + "settings": { + "cookie_jar": { + "analytical": true, + "functional": true, + "marketing": false, + "social": false + }, + "django": { + "description": "", + "domain": "phase2a_test_20260222013532.nl", + "email_from": "webshop@mandelblog.com", + "email_host": "vps.transip.email", + "email_host_password": "CHANGE_ME", + "email_host_user": "noreply@mandelblog.com", + "email_port": "587", + "email_to": "info@phase2a_test_20260222013532.nl", + "email_use_tls": true, + "language_code": "nl", + "name": "phase2a_test_20260222013532", + "username": "administrator" + }, + "sentry logging": { + "dsn_secret": "https://c83311f3bba3ba41c20e586a2594553e:7943173a6997d212d14e3e110deeedf7@sentry.mandelblog.com/38" + }, + "themes": { + "theme": "default", + "theme-switcher": false + }, + "wagtail": { + "wagtailuserbar_position": "bottom-right" + }, + "wagtail content page": { + "actionbuttons": false, + "add_to_cart": false, + "heading": true, + "html": false, + "image": true, + "paragraph": true, + "table": true + }, + "wagtail_blog": { + "items_per_page": 10 + } + } +} diff --git a/phase2a_test_20260222013532/settings/__init__.py b/phase2a_test_20260222013532/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/settings/base.py b/phase2a_test_20260222013532/settings/base.py new file mode 100644 index 0000000..9fa6462 --- /dev/null +++ b/phase2a_test_20260222013532/settings/base.py @@ -0,0 +1,36 @@ +""" +Django settings for de tilde project. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.0/ref/settings/ +""" + +from pathlib import Path + +from configtype.jsonconfig import setup_search_paths + +_project_app_path = Path(__file__).parent.parent +BASE_PATH = _project_app_path.parent +BASE_DIR = str(BASE_PATH) + +setup_search_paths("/etc/ocyan/", str(_project_app_path)) + +from ocyan.main.settings import * # pylint:disable=W0401,W0614 + +INSTALLED_APPS = ["phase2a_test_20260222013532"] + INSTALLED_APPS + +STATIC_ROOT = str(BASE_PATH / "static") +MEDIA_ROOT = str(BASE_PATH / "media") +PRIVATE_MEDIA_ROOT = str(BASE_PATH / "private") + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": str(BASE_PATH / "db.sqlite3"), + } +} + +SECRET_KEY = "3$md^o$3fm5!4pfbo0+#p$4ilvb1%13nyrg&*0gr&cc9h9(l!^" diff --git a/phase2a_test_20260222013532/settings/env/__init__.py b/phase2a_test_20260222013532/settings/env/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/settings/env/dev.py b/phase2a_test_20260222013532/settings/env/dev.py new file mode 100644 index 0000000..6b2d6f6 --- /dev/null +++ b/phase2a_test_20260222013532/settings/env/dev.py @@ -0,0 +1,21 @@ +from ..base import * # pylint:disable=W0401,W0614 + +try: + from phase2a_test_20260222013532.json import * # pylint:disable=W0401,W0614,E0611,E0401 +except ModuleNotFoundError: + pass + +DEBUG = False +STATIC_ROOT = "/srv/www/phase2a_test_20260222013532/static/" +MEDIA_ROOT = "/srv/www/phase2a_test_20260222013532/media/" +PRIVATE_MEDIA_ROOT = "/srv/www/phase2a_test_20260222013532/private/" + +ALLOWED_HOSTS = ["*"] + +# Force mail to console +EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +EDEN_URL = ["https://search.mandelblog.com:9200"] +# pylint: disable=E0602 +WAGTAILSEARCH_BACKENDS["default"]["URLS"] = EDEN_URL +OSCAR_ELASTICSEARCH_SERVER_URLS = EDEN_URL diff --git a/phase2a_test_20260222013532/settings/env/prd.py b/phase2a_test_20260222013532/settings/env/prd.py new file mode 100644 index 0000000..be53165 --- /dev/null +++ b/phase2a_test_20260222013532/settings/env/prd.py @@ -0,0 +1,15 @@ +from ..base import * # pylint:disable=W0401,W0614 + +try: + from phase2a_test_20260222013532.json import * # pylint:disable=W0401,W0614,E0611,E0401 +except ModuleNotFoundError: + pass + +DEBUG = False +STATIC_ROOT = "/srv/www/phase2a_test_20260222013532/static/" +MEDIA_ROOT = "/srv/www/phase2a_test_20260222013532/media/" +PRIVATE_MEDIA_ROOT = "/srv/www/phase2a_test_20260222013532/private/" +ALLOWED_HOSTS.append("phase2a_test_20260222013532.%s" % salt_target) # pylint: disable=E0602 +# pylint: disable=E0602 +WAGTAILSEARCH_BACKENDS["default"]["URLS"] = ["https://search.mandelblog.com:9200"] +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" diff --git a/phase2a_test_20260222013532/settings/env/stg.py b/phase2a_test_20260222013532/settings/env/stg.py new file mode 100644 index 0000000..96e7e79 --- /dev/null +++ b/phase2a_test_20260222013532/settings/env/stg.py @@ -0,0 +1,16 @@ +from ..base import * # pylint:disable=W0401,W0614 + +try: + from phase2a_test_20260222013532.json import * # pylint:disable=W0401,W0614,E0611,E0401 +except ModuleNotFoundError: + pass + +DEBUG = False +STATIC_ROOT = "/srv/www/phase2a_test_20260222013532/static/" +MEDIA_ROOT = "/srv/www/phase2a_test_20260222013532/media/" +PRIVATE_MEDIA_ROOT = "/srv/www/phase2a_test_20260222013532/private/" + +ALLOWED_HOSTS = ["*"] + +# Force mail to console +EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" diff --git a/phase2a_test_20260222013532/static/phase2a_test_20260222013532/css/.gitkeep b/phase2a_test_20260222013532/static/phase2a_test_20260222013532/css/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/static/phase2a_test_20260222013532/img/.gitignore b/phase2a_test_20260222013532/static/phase2a_test_20260222013532/img/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/static/phase2a_test_20260222013532/js/.gitignore b/phase2a_test_20260222013532/static/phase2a_test_20260222013532/js/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/templates/phase2a_test_20260222013532/.gitignore b/phase2a_test_20260222013532/templates/phase2a_test_20260222013532/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/phase2a_test_20260222013532/wsgi.py b/phase2a_test_20260222013532/wsgi.py new file mode 100644 index 0000000..814ed47 --- /dev/null +++ b/phase2a_test_20260222013532/wsgi.py @@ -0,0 +1 @@ +from ocyan.main.wsgi import application # pylint: disable=W0611 diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..f03736d --- /dev/null +++ b/pylintrc @@ -0,0 +1,12 @@ +[MASTER] +jobs = 1 +load-plugins = pylint_django,pylint_packageinitcheck +django-settings-module = phase2a_test_20260222013532.settings.base +score = n +ignore = migrations + +[MESSAGES CONTROL] +disable = R,C,W5103,W0707,E5110 + +[TYPECHECK] +ignored-classes = responses diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a3ba637 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,30 @@ +[tool.black] +target_version = ['py36'] +exclude = ''' +( + migrations/* + | phase2a_test_20260222013532/main.py +) +''' + +[tool.ruff.lint.isort] +known-first-party = ["phase2a_test_20260222013532"] +section-order = [ + "future", + "standard-library", + "third-party", + "wagtail", + "oscar", + "oscarapi", + "oscarextra", + "ocyan", + "first-party", + "local-folder" +] + +[tool.ruff.lint.isort.sections] +wagtail = ["wagtail", "wagtail_*"] +oscar = ["oscar"] +oscarapi = ["oscarapi"] +oscarextra = ["oscar_*"] +ocyan = ["ocyan"] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f41393b --- /dev/null +++ b/setup.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +import json + +from setuptools import find_packages, setup + +install_requires: list = ["setuptools", "ocyan.main"] + +# Add frets dependencies +with open("phase2a_test_20260222013532/ocyan.json", encoding="utf-8") as fp: + config = json.loads(fp.read()) + install_requires.extend(config["ocyan_plugins"]) + +extras_require: dict = { + "test": [ + "pylint-django", + "vdt.versionplugin.wheel", + "coverage", + "ocyan.plugin.testing", + ], + "prd": ["psycopg2-binary"], +} + +PACKAGE_CLASSIFIERS = [ + "License :: Other/Proprietary License", + "Framework :: Ocyan", +] + +setup( + name="mandel-phase2a_test_20260222013532", + version="0.1.0", + url="https://git.mandelblog.com/mandel-projects/phase2a_test_20260222013532", + author="Motolani Olaiya", + author_email="motolaniolaiya@gmail.com", + description="Ocyan project: phase2a_test_20260222013532", + packages=find_packages(), + include_package_data=True, + python_requires=">=3.10", + install_requires=install_requires, + extras_require=extras_require, + entry_points={"console_scripts": ["manage.py=phase2a_test_20260222013532.main:main"]}, + classifiers=PACKAGE_CLASSIFIERS, +) diff --git a/uwsgi-dev.ini b/uwsgi-dev.ini new file mode 100644 index 0000000..03d38c8 --- /dev/null +++ b/uwsgi-dev.ini @@ -0,0 +1,28 @@ +[uwsgi] +master = true +chmod-socket = 660 +workers = 1 +reload-mercy = 30 +vacuum = 1 +auto-procname = true +enable-threads = false +lazy = 0 +no-orphans = true +stats = 127.0.0.1:9191 +thunder-lock = false +enable-threads = true + +# dev settings +python-autoreload = 1 +http = 127.0.0.1:8000 +if-env = VIRTUAL_ENV +virtualenv = %(_) +endif = + +# Django settings +env = DJANGO_SETTINGS_MODULE=phase2a_test_20260222013532.settings.base +module = phase2a_test_20260222013532.wsgi:application + +# Spoolers +spooler = spooler +spooler-chdir = %d