-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from moshthepitt/issue-15
Add support for configurable templates
- Loading branch information
Showing
50 changed files
with
11,376 additions
and
44 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ArtistsConfig(AppConfig): | ||
name = 'artists' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by Django 2.1.4 on 2018-12-30 09:49 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Artist', | ||
fields=[ | ||
('id', | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='ID')), | ||
('name', models.CharField(max_length=100, | ||
verbose_name='Name')), | ||
], | ||
options={ | ||
'verbose_name': 'Artist', | ||
'verbose_name_plural': 'Artists', | ||
'ordering': ['name'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Song', | ||
fields=[ | ||
('id', | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name='ID')), | ||
('name', models.CharField(max_length=100, | ||
verbose_name='Name')), | ||
('artist', | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.PROTECT, | ||
to='artists.Artist', | ||
verbose_name='Artist')), | ||
], | ||
options={ | ||
'verbose_name': 'Song', | ||
'verbose_name_plural': 'Songs', | ||
'ordering': ['name'], | ||
}, | ||
), | ||
] |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Module for vega-admin test models | ||
""" | ||
from django.db import models | ||
from django.utils.translation import ugettext as _ | ||
|
||
|
||
class Artist(models.Model): | ||
""" | ||
Artist Model class | ||
""" | ||
name = models.CharField(_("Name"), max_length=100) | ||
|
||
class Meta: | ||
ordering = ['name'] | ||
verbose_name = 'Artist' | ||
verbose_name_plural = 'Artists' | ||
|
||
def __str__(self): | ||
"""Unicode representation of Song.""" | ||
return self.name | ||
|
||
|
||
class Song(models.Model): | ||
"""Model definition for Song.""" | ||
artist = models.ForeignKey( | ||
Artist, verbose_name=_("Artist"), on_delete=models.PROTECT) | ||
name = models.CharField(_("Name"), max_length=100) | ||
|
||
class Meta: | ||
"""Meta definition for Song.""" | ||
verbose_name = 'Song' | ||
verbose_name_plural = 'Songs' | ||
ordering = ['name'] | ||
|
||
def __str__(self): | ||
"""Unicode representation of Song.""" | ||
return self.name |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Artist app views module""" | ||
from vega_admin.views import VegaCRUDView, VegaListView | ||
|
||
from .models import Artist, Song | ||
|
||
|
||
class ArtistCRUD(VegaCRUDView): | ||
""" | ||
CRUD view for artists | ||
""" | ||
|
||
model = Artist | ||
protected_actions = None | ||
permissions_actions = None | ||
|
||
|
||
class SongCRUD(VegaCRUDView): | ||
""" | ||
CRUD view for songs | ||
""" | ||
|
||
class CustomListView(VegaListView): | ||
"""Custom list view""" | ||
model = Artist | ||
|
||
model = Song | ||
protected_actions = None | ||
permissions_actions = None | ||
list_fields = ["name", "artist", ] | ||
read_fields = ["name", "artist", ] | ||
table_attrs = {"class": "table song-table"} | ||
table_actions = ["create", "artists", "update", "delete", ] | ||
create_fields = ["name", "artist", ] | ||
update_fields = ["name", ] | ||
view_classes = { | ||
"artists": CustomListView, | ||
} |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
""" | ||
Django settings for example project. | ||
Generated by 'django-admin startproject' using Django 2.1.3. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/2.1/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/2.1/ref/settings/ | ||
""" | ||
|
||
import os | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
# Quick-start development settings - unsuitable for production | ||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = '4^lzr3=(u=(!-25j@dwzzem4*&e5!7*$9f!gpj_+_ely6x&2aq' | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = True | ||
|
||
ALLOWED_HOSTS = [] | ||
|
||
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'crispy_forms', | ||
'django_tables2', | ||
'django_filters', | ||
'vega_admin', | ||
'artists', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
] | ||
|
||
ROOT_URLCONF = 'example.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'example.wsgi.application' | ||
|
||
# Database | ||
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
} | ||
} | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': | ||
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', # noqa | ||
}, | ||
{ | ||
'NAME': | ||
'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': | ||
'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': | ||
'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/2.1/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_L10N = True | ||
|
||
USE_TZ = True | ||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/2.1/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
|
||
# vega settings | ||
CRISPY_TEMPLATE_PACK = 'bootstrap3' | ||
VEGA_TEMPLATE = 'badmin' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""example URL Configuration""" | ||
from artists import views | ||
|
||
urlpatterns = views.ArtistCRUD().url_patterns() +\ | ||
views.SongCRUD().url_patterns() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for example project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'example.settings') | ||
|
||
application = get_wsgi_application() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
if __name__ == '__main__': | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'example.settings') | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) from exc | ||
execute_from_command_line(sys.argv) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.