initial commit
This commit is contained in:
commit
f3f3b0e68f
|
@ -0,0 +1 @@
|
||||||
|
3.11
|
|
@ -0,0 +1,103 @@
|
||||||
|
name: Code Style
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
paths-ignore:
|
||||||
|
- 'pretalx_musicrate/locale/**'
|
||||||
|
- 'pretalx_musicrate/static/**'
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
paths-ignore:
|
||||||
|
- 'pretalx_musicrate/locale/**'
|
||||||
|
- 'pretalx_musicrate/static/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
isort:
|
||||||
|
name: isort
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: install gettext
|
||||||
|
run: sudo apt install gettext
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version-file: ".github/workflows/python-version.txt"
|
||||||
|
cache: "pip"
|
||||||
|
- name: Install isort
|
||||||
|
run: pip3 install isort
|
||||||
|
- name: Run isort
|
||||||
|
run: isort -c .
|
||||||
|
flake:
|
||||||
|
name: flake8
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: install gettext
|
||||||
|
run: sudo apt install gettext
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version-file: ".github/workflows/python-version.txt"
|
||||||
|
cache: "pip"
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pip3 install flake8 flake8-bugbear
|
||||||
|
- name: Run flake8
|
||||||
|
run: flake8 .
|
||||||
|
working-directory: .
|
||||||
|
black:
|
||||||
|
name: black
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: install gettext
|
||||||
|
run: sudo apt install gettext
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version-file: ".github/workflows/python-version.txt"
|
||||||
|
cache: "pip"
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pip3 install black
|
||||||
|
- name: Run black
|
||||||
|
run: black --check .
|
||||||
|
working-directory: .
|
||||||
|
djhtml:
|
||||||
|
name: djhtml
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: install gettext
|
||||||
|
run: sudo apt install gettext
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version-file: ".github/workflows/python-version.txt"
|
||||||
|
cache: "pip"
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pip3 install djhtml
|
||||||
|
- name: Run docformatter
|
||||||
|
run: find -name "*.html" | xargs djhtml -c
|
||||||
|
working-directory: .
|
||||||
|
packaging:
|
||||||
|
name: packaging
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version-file: ".github/workflows/python-version.txt"
|
||||||
|
cache: "pip"
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pip3 install twine check-manifest -Ue .
|
||||||
|
- name: Run check-manifest
|
||||||
|
run: check-manifest .
|
||||||
|
working-directory: .
|
||||||
|
- name: Build package
|
||||||
|
run: python -m build
|
||||||
|
working-directory: .
|
||||||
|
- name: Check package
|
||||||
|
run: twine check dist/*
|
||||||
|
working-directory: .
|
|
@ -0,0 +1,88 @@
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
env/
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
.ropeproject/
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*,cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
*.toc
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
|
||||||
|
# editors
|
||||||
|
*.swp
|
||||||
|
*.aux
|
||||||
|
*~
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# IDEA / pycharm
|
||||||
|
.idea/
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# generic local files
|
||||||
|
local/
|
||||||
|
*.xml
|
||||||
|
pretalx.cfg
|
||||||
|
|
||||||
|
# OS X
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
.pytest_cache
|
||||||
|
*.cfg
|
|
@ -0,0 +1,13 @@
|
||||||
|
Copyright 2023 Luca
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,6 @@
|
||||||
|
recursive-include pretalx_musicrate/static *
|
||||||
|
recursive-include pretalx_musicrate/templates *
|
||||||
|
exclude pretalx_musicrate/locale/django.pot
|
||||||
|
recursive-include pretalx_musicrate/locale *
|
||||||
|
recursive-include pretalx_musicrate *.py
|
||||||
|
include Makefile
|
|
@ -0,0 +1,10 @@
|
||||||
|
all: localecompile
|
||||||
|
LNGS:=`find pretalx_musicrate/locale/ -mindepth 1 -maxdepth 1 -type d -printf "-l %f "`
|
||||||
|
|
||||||
|
localecompile:
|
||||||
|
django-admin compilemessages
|
||||||
|
|
||||||
|
localegen:
|
||||||
|
django-admin makemessages -l de_DE -i build -i dist -i "*egg*" $(LNGS)
|
||||||
|
|
||||||
|
.PHONY: all localecompile localegen
|
|
@ -0,0 +1,48 @@
|
||||||
|
pretalx musicrate plugin
|
||||||
|
==========================
|
||||||
|
|
||||||
|
This is a plugin for `pretalx`_.
|
||||||
|
pretalx plugin for rating music
|
||||||
|
|
||||||
|
Development setup
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
1. Make sure that you have a working `pretalx development setup`_.
|
||||||
|
|
||||||
|
2. Clone this repository, eg to ``local/pretalx-musicrate``.
|
||||||
|
|
||||||
|
3. Activate the virtual environment you use for pretalx development.
|
||||||
|
|
||||||
|
4. Run ``pip install -e .`` within this directory to register this application with pretalx's plugin registry.
|
||||||
|
|
||||||
|
5. Run ``make`` within this directory to compile translations.
|
||||||
|
|
||||||
|
6. Restart your local pretalx server. This plugin should show up in the plugin list shown on startup in the console.
|
||||||
|
You can now use the plugin from this repository for your events by enabling it in the 'plugins' tab in the settings.
|
||||||
|
|
||||||
|
This plugin has CI set up to enforce a few code style rules. To check locally, you need these packages installed::
|
||||||
|
|
||||||
|
pip install flake8 flake8-bugbear isort black
|
||||||
|
|
||||||
|
To check your plugin for rule violations, run::
|
||||||
|
|
||||||
|
black --check .
|
||||||
|
isort -c .
|
||||||
|
flake8 .
|
||||||
|
|
||||||
|
You can auto-fix some of these issues by running::
|
||||||
|
|
||||||
|
isort .
|
||||||
|
black .
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
Copyright 2023 Luca
|
||||||
|
|
||||||
|
Released under the terms of the Apache License 2.0
|
||||||
|
|
||||||
|
|
||||||
|
.. _pretalx: https://github.com/pretalx/pretalx
|
||||||
|
.. _pretalx development setup: https://docs.pretalx.org/en/latest/developer/setup.html
|
|
@ -0,0 +1 @@
|
||||||
|
__version__ = "0.0.1"
|
|
@ -0,0 +1,20 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
from django.utils.translation import gettext_lazy
|
||||||
|
|
||||||
|
from . import __version__
|
||||||
|
|
||||||
|
|
||||||
|
class PluginApp(AppConfig):
|
||||||
|
name = "pretalx_musicrate"
|
||||||
|
verbose_name = "pretalx musicrate plugin"
|
||||||
|
|
||||||
|
class PretalxPluginMeta:
|
||||||
|
name = gettext_lazy("pretalx musicrate plugin")
|
||||||
|
author = "Luca"
|
||||||
|
description = gettext_lazy("pretalx plugin for rating music")
|
||||||
|
visible = True
|
||||||
|
version = __version__
|
||||||
|
category = "FEATURE"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
from . import signals # NOQA
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
from i18nfield.forms import I18nModelForm
|
||||||
|
|
||||||
|
from .models import MusicrateSettings
|
||||||
|
|
||||||
|
|
||||||
|
class MusicrateSettingsForm(I18nModelForm):
|
||||||
|
|
||||||
|
def __init__(self, *args, event=None, **kwargs):
|
||||||
|
self.instance, _ = MusicrateSettings.objects.get_or_create(event=event)
|
||||||
|
super().__init__(*args, **kwargs, instance=self.instance, locales=event.locales)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = MusicrateSettings
|
||||||
|
fields = ("some_setting", )
|
||||||
|
widgets = {}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MusicrateSettings(models.Model):
|
||||||
|
event = models.OneToOneField(
|
||||||
|
to="event.Event",
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
related_name="pretalx_musicrate_settings",
|
||||||
|
)
|
||||||
|
some_setting = models.CharField(max_length=10, default="A")
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
from django.dispatch import receiver
|
||||||
|
from django.urls import reverse
|
||||||
|
from pretalx.orga.signals import nav_event_settings
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(nav_event_settings)
|
||||||
|
def pretalx_musicrate_settings(sender, request, **kwargs):
|
||||||
|
if not request.user.has_perm("orga.change_settings", request.event):
|
||||||
|
return []
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"label": "pretalx musicrate plugin",
|
||||||
|
"url": reverse(
|
||||||
|
"plugins:pretalx_musicrate:settings",
|
||||||
|
kwargs={"event": request.event.slug},
|
||||||
|
),
|
||||||
|
"active": request.resolver_match.url_name
|
||||||
|
== "plugins:pretalx_musicrate:settings",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
from django.urls import re_path
|
||||||
|
from pretalx.event.models.event import SLUG_REGEX
|
||||||
|
|
||||||
|
from .views import MusicrateSettings
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
re_path(
|
||||||
|
rf"^orga/event/(?P<event>{SLUG_REGEX})/settings/p/pretalx_musicrate/$",
|
||||||
|
MusicrateSettings.as_view(),
|
||||||
|
name="settings",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.views.generic import FormView
|
||||||
|
from pretalx.common.mixins.views import PermissionRequired
|
||||||
|
|
||||||
|
|
||||||
|
from .forms import MusicrateSettingsForm
|
||||||
|
|
||||||
|
|
||||||
|
class MusicrateSettingsView(PermissionRequired, FormView):
|
||||||
|
permission_required = "orga.change_settings"
|
||||||
|
template_name = "pretalx_musicrate/settings.html"
|
||||||
|
form_class = MusicrateSettingsForm
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return self.request.path
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
return self.request.event
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super().get_form_kwargs()
|
||||||
|
kwargs["event"] = self.request.event
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.save()
|
||||||
|
messages.success(self.request, _("The pretalx musicrate plugin settings were updated."))
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
[project]
|
||||||
|
name = "pretalx-musicrate"
|
||||||
|
dynamic = ["version"]
|
||||||
|
description = "pretalx plugin for rating music"
|
||||||
|
readme = "README.rst"
|
||||||
|
license = {text = "Apache Software License"}
|
||||||
|
keywords = ["pretalx"]
|
||||||
|
authors = [
|
||||||
|
{name = "Luca", email = "Luca@hackerspace-bamberg.de"},
|
||||||
|
]
|
||||||
|
maintainers = [
|
||||||
|
{name = "Luca", email = "Luca@hackerspace-bamberg.de"},
|
||||||
|
]
|
||||||
|
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
homepage = "https://git.luj0ga.de/kontakt/pretalx-musicrate"
|
||||||
|
repository = "https://git.luj0ga.de/kontakt/pretalx-musicrate.git"
|
||||||
|
|
||||||
|
[project.entry-points."pretalx.plugin"]
|
||||||
|
pretalx_musicrate = "pretalx_musicrate:PretalxPluginMeta"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
requires = ["setuptools"]
|
||||||
|
|
||||||
|
[tool.setuptools]
|
||||||
|
include-package-data = true
|
||||||
|
|
||||||
|
[tool.setuptools.dynamic]
|
||||||
|
version = {attr = "pretalx_musicrate.__version__"}
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
include = ["pretalx*"]
|
||||||
|
|
||||||
|
[tool.check-manifest]
|
||||||
|
ignore = [".*"]
|
Loading…
Reference in New Issue