From 8262864be98ad12e4bbf868d4f481f7a675d5a41 Mon Sep 17 00:00:00 2001 From: Tomas Gavenciak Date: Sat, 14 Mar 2015 00:33:35 +0100 Subject: [PATCH] Remove feincms, revert some experiments --- mamweb/settings.py | 169 +------------------------------------ mamweb/settings_common.py | 171 ++++++++++++++++++++++++++++++++++++++ mamweb/settings_prod.py | 2 + mamweb/settings_test.py | 2 + seminar/admin.py | 7 +- seminar/models.py | 26 +----- 6 files changed, 182 insertions(+), 195 deletions(-) create mode 100644 mamweb/settings_common.py create mode 100644 mamweb/settings_prod.py create mode 100644 mamweb/settings_test.py diff --git a/mamweb/settings.py b/mamweb/settings.py index a2e00263..99d19c6f 100644 --- a/mamweb/settings.py +++ b/mamweb/settings.py @@ -1,169 +1,2 @@ -""" -Django settings for mamweb project. +from .settings_common import * -For more information on this file, see -https://docs.djangoproject.com/en/1.7/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.7/ref/settings/ -""" - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -import os -BASE_DIR = os.path.dirname(os.path.dirname(__file__)) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = ')^u=i65*zmr_k53a*@f4q_+ji^o@!pgpef*5&8c7zzv9l+zo)n' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -TEMPLATE_DEBUG = True - -ALLOWED_HOSTS = [] - - -AUTHENTICATION_BACKENDS = ( - # Needed to login by username in Django admin, regardless of `allauth` - 'django.contrib.auth.backends.ModelBackend', - # `allauth` specific authentication methods, such as login by e-mail - 'allauth.account.auth_backends.AuthenticationBackend', -) - - - -# Application definition - -SITE_ID = 1 - -ROOT_URLCONF = 'mamweb.urls' - -WSGI_APPLICATION = 'mamweb.wsgi.application' - - -# Internationalization -# https://docs.djangoproject.com/en/1.7/topics/i18n/ - -LANGUAGE_CODE = 'cs' - -TIME_ZONE = 'Europe/Prague' - -USE_I18N = False - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.7/howto/static-files/ - -STATIC_URL = '/static/' -MEDIA_URL = '/media/' -MEDIA_ROOT = os.path.join(BASE_DIR, 'media') -STATIC_ROOT = os.path.join(BASE_DIR, 'static') - -STATICFILES_DIRS = ( - os.path.join(BASE_DIR, 'mamweb', 'static'), -) - -STATICFILES_FINDERS = ( - 'django.contrib.staticfiles.finders.AppDirectoriesFinder', - 'django.contrib.staticfiles.finders.FileSystemFinder', -) - -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - 'django.template.loaders.eggs.Loader' -) - -MIDDLEWARE_CLASSES = ( - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - 'django.core.context_processors.i18n', - 'django.core.context_processors.debug', - 'django.core.context_processors.request', - 'django.core.context_processors.media', - 'django.core.context_processors.csrf', - 'django.core.context_processors.tz', - 'sekizai.context_processors.sekizai', - 'django.core.context_processors.static', - 'allauth.account.context_processors.account', - 'allauth.socialaccount.context_processors.socialaccount', -) - - -INSTALLED_APPS = ( - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.sites', - 'django.contrib.staticfiles', - - 'sekizai', - 'reversion', - 'feincms', - - 'allauth', - 'allauth.account', - 'allauth.socialaccount', -# 'allauth.socialaccount.providers.facebook', -# 'allauth.socialaccount.providers.openid', - 'allauth.socialaccount.providers.google', - - 'mamweb', - 'seminar', -) - -# Database -# https://docs.djangoproject.com/en/1.7/ref/settings/#databases - -DATABASES = { - 'default': { -# 'ENGINE': 'django.db.backends.postgresql_psycopg2', -# 'NAME': 'mam', -# 'USER': 'mam', -# }, -# 'test': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - - -SOCIALACCOUNT_QUERY_EMAIL = True -SOCIALACCOUNT_PROVIDERS = { - 'google': { - 'SCOPE': ['profile', 'email'], - 'AUTH_PARAMS': { 'access_type': 'online' } - }, - 'facebook': { - 'SCOPE': ['email', 'publish_stream'], - 'METHOD': 'js_sdk', - 'VERIFIED_EMAIL': True, - } -} -ACCOUNT_AUTHENTICATION_METHOD = 'username_email' -ACCOUNT_EMAIL_REQUIRED = True -SOCIALACCOUNT_EMAIL_REQUIRED = True - -# MaM specific - -SEMINAR_RESENI_DIRNAME = 'reseni' diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py new file mode 100644 index 00000000..4e622f6f --- /dev/null +++ b/mamweb/settings_common.py @@ -0,0 +1,171 @@ +""" +Django settings for mamweb project. + +For more information on this file, see +https://docs.djangoproject.com/en/1.7/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.7/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = ')^u=i65*zmr_k53a*@f4q_+ji^o@!pgpef*5&8c7zzv9l+zo)n' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +TEMPLATE_DEBUG = True + +ALLOWED_HOSTS = [] + + +AUTHENTICATION_BACKENDS = ( + # Needed to login by username in Django admin, regardless of `allauth` + 'django.contrib.auth.backends.ModelBackend', + # `allauth` specific authentication methods, such as login by e-mail + 'allauth.account.auth_backends.AuthenticationBackend', +) + + + +# Application definition + +SITE_ID = 1 + +ROOT_URLCONF = 'mamweb.urls' + +WSGI_APPLICATION = 'mamweb.wsgi.application' + + +# Internationalization +# https://docs.djangoproject.com/en/1.7/topics/i18n/ + +LANGUAGE_CODE = 'cs' + +TIME_ZONE = 'Europe/Prague' + +USE_I18N = False + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.7/howto/static-files/ + +STATIC_URL = '/static/' +MEDIA_URL = '/media/' +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +STATIC_ROOT = os.path.join(BASE_DIR, 'static') + +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'mamweb', 'static'), +) + +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', +) + +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + 'django.template.loaders.eggs.Loader' +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + 'django.core.context_processors.i18n', + 'django.core.context_processors.debug', + 'django.core.context_processors.request', + 'django.core.context_processors.media', + 'django.core.context_processors.csrf', + 'django.core.context_processors.tz', + 'sekizai.context_processors.sekizai', + 'django.core.context_processors.static', + 'allauth.account.context_processors.account', + 'allauth.socialaccount.context_processors.socialaccount', +) + + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.sites', + 'django.contrib.staticfiles', + + 'sekizai', + 'reversion', + + 'allauth', + 'allauth.account', + 'allauth.socialaccount', +# 'allauth.socialaccount.providers.facebook', +# 'allauth.socialaccount.providers.openid', + 'allauth.socialaccount.providers.google', + + + 'mamweb', + 'seminar', +) + +# Database +# https://docs.djangoproject.com/en/1.7/ref/settings/#databases + +DATABASES = { + 'default': { +# 'ENGINE': 'django.db.backends.postgresql_psycopg2', +# 'NAME': 'mam', +# 'USER': 'mam', +# }, +# 'test': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +SOCIALACCOUNT_QUERY_EMAIL = True +SOCIALACCOUNT_PROVIDERS = { + 'google': { + 'SCOPE': ['profile', 'email'], + 'AUTH_PARAMS': { 'access_type': 'online' } + }, + 'facebook': { + 'SCOPE': ['email', 'publish_stream'], + 'METHOD': 'js_sdk', + 'VERIFIED_EMAIL': True, + } +} +ACCOUNT_AUTHENTICATION_METHOD = 'username_email' +ACCOUNT_EMAIL_REQUIRED = True +SOCIALACCOUNT_EMAIL_REQUIRED = True + +# MaM specific + +SEMINAR_RESENI_DIRNAME = 'reseni' + + diff --git a/mamweb/settings_prod.py b/mamweb/settings_prod.py new file mode 100644 index 00000000..df64815e --- /dev/null +++ b/mamweb/settings_prod.py @@ -0,0 +1,2 @@ +from .settings import * + diff --git a/mamweb/settings_test.py b/mamweb/settings_test.py new file mode 100644 index 00000000..df64815e --- /dev/null +++ b/mamweb/settings_test.py @@ -0,0 +1,2 @@ +from .settings import * + diff --git a/seminar/admin.py b/seminar/admin.py index 2a13c390..9a8c60f8 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -101,18 +101,17 @@ class ReseniInline(admin.StackedInline): ### Problem -from feincms.admin import item_editor -class ProblemAdmin(item_editor.ItemEditor): +class ProblemAdmin(admin.ModelAdmin): # readonly_fields = ['autor'] fieldsets = [ (None, {'fields': ['nazev', 'typ', 'stav', 'autor']}), (u'Vydání', {'fields': ['cislo_zadani', 'kod', 'cislo_reseni', 'opravovatel']}), - item_editor.FEINCMS_CONTENT_FIELDSET, + (u'Texty', {'fields': ['text_problemu', 'text_problemu_org']}), ] list_display = ['nazev', 'typ', 'stav', 'autor', 'kod', 'opravovatel'] list_filter = ['typ', 'stav', 'autor', 'opravovatel'] - search_fields = ['nazev', 'autor', 'kod']#, 'text_problemu_org', 'text_problemu'] + search_fields = ['nazev', 'autor', 'kod', 'text_problemu_org', 'text_problemu'] inlines = [ReseniInline] admin.site.register(Problem, ProblemAdmin) diff --git a/seminar/models.py b/seminar/models.py index f8f704ca..3e84b1e5 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -10,8 +10,6 @@ from django.conf import settings from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import force_unicode -from feincms.models import Base - # # Mělo by být částečně vytaženo z Aesopa # viz https://ovvp.mff.cuni.cz/wiki/aesop/export-skol. @@ -185,7 +183,7 @@ class Cislo(models.Model): @python_2_unicode_compatible -class Problem(Base): +class Problem(models.Model): class Meta: db_table = 'seminar_problemy' @@ -222,11 +220,9 @@ class Problem(Base): ] stav = models.CharField(u'stav problému', max_length=32, choices=STAV_CHOICES, blank=False, default=STAV_NAVRH) -# text_problemu_org = PlaceholderField('text_problemu_org', related_name='problem_text_org', -# verbose_name=u'organizátorský (neveřejný) text') + text_problemu_org = models.TextField(u'organizátorský (neveřejný) text', blank=True) -# text_problemu = PlaceholderField('text_problemu', related_name='problem_text', -# verbose_name=u'veřejný text zadání a řešení') + text_problemu = models.TextField(u'veřejný text zadání a řešení', blank=True) autor = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=u'autor problému', related_name='autor_uloh') @@ -244,22 +240,6 @@ class Problem(Base): def __str__(self): return force_unicode(u'%s (%s)' % (self.nazev, self.stav)) -from feincms.content.richtext.models import RichTextContent -from feincms.content.image.models import ImageContent -from feincms.content.medialibrary.models import MediaFileContent - -Problem.register_regions( - ('text_problemu', 'uveřejný text zadání a řešení'), - ('text_problemu_org', u'organizátorský (neveřejný) text') - ) -Problem.create_content_type(RichTextContent) -Problem.create_content_type( - ImageContent, - POSITION_CHOICES=( - ('default', 'Default position'), - ) - ) - @python_2_unicode_compatible class Reseni(models.Model):