This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.auth import get_user_model | |
| from django.test import Client | |
| def call_endpoint(url: str, verb: str, credentials: dict | None): | |
| """Call the endpoint providing a url, a verb and optional credentials.""" | |
| client = Client() | |
| if credentials is not None: | |
| user = get_user_model().objects.get(**credentials) | |
| client.force_login(user) | |
| return getattr(client, verb)(url, SERVER_NAME="localhost") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import date | |
| from django.forms.widgets import DateInput as DjangoDateInput | |
| class DateInput(DjangoDateInput): | |
| """Custom select date widget.""" | |
| input_type = "date" | |
| offset_years = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Wagtail models.""" | |
| from django.db.models import CASCADE, Model | |
| from modelcluster.contrib.taggit import ClusterTaggableManager | |
| from taggit.models import TaggedItemBase | |
| from wagtail.models import Page, ParentalKey | |
| TAG_FIELDS = [ | |
| ("Tag Category 1", "tag_category_1"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM python:3.11-slim-bookworm | |
| RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg | |
| RUN sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends \ | |
| postgresql-client-16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Path = require('path'), | |
| NodeExternals = require('webpack-node-externals'), | |
| Copy = require('copy-webpack-plugin'), | |
| Obfuscator = require('webpack-obfuscator') | |
| module.exports = { | |
| context: __dirname, | |
| mode: 'production', | |
| target: 'electron-main', | |
| entry: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [build-system] | |
| build-backend = "setuptools.build_meta" | |
| requires = [ | |
| "setuptools", | |
| "wheel", | |
| ] | |
| [project] | |
| name = "Django Project" | |
| version = "0.0.1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Text utils.""" | |
| def strip_bom(value): | |
| """Strip Byte Order Mark from UTF-8 text.""" | |
| return value.encode("utf-8").decode("utf-8-sig") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Django storages.""" | |
| from django.core.files.storage import FileSystemStorage | |
| class FileSystemOverwriteStorage(FileSystemStorage): | |
| """A file system storage with file overwriting capabilities.""" | |
| def get_available_name(self, name, max_length=None): | |
| """Return the available name.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Django filters.""" | |
| from django.contrib.admin import SimpleListFilter | |
| class ArrayFieldListFilter(SimpleListFilter): | |
| """An admin list filter for ArrayFields.""" | |
| def lookups(self, request, model_admin): | |
| """Return the lookups.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FieldPermissionsMixin: | |
| """ | |
| Define a mixin handling read-only fields per group, admin model and form type. | |
| !!!THIS IS JUST A DRAFT, AWAITING COMPLETION!!! | |
| Read-only fields can be specified in a setting exemplified below. | |
| For permission names, codenames without the model name are considered well-formed. | |
| GROUPS = { |
NewerOlder