mirror of
https://github.com/AxioDL/axiodl-www.git
synced 2026-07-11 06:19:06 -07:00
Restructure codebase, more imps, better views
This commit is contained in:
@@ -3,3 +3,4 @@ from django.apps import AppConfig
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
name = 'accounts'
|
||||
verbose_name = 'AxioDL - Accounts'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Django settings for www project.
|
||||
Django settings for axiodl project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 2.2.2.
|
||||
|
||||
@@ -9,13 +9,13 @@ https://docs.djangoproject.com/en/2.2/topics/settings/
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||
"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from .sitesettings import configuration
|
||||
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.2/howto/deployment/checklist/
|
||||
|
||||
@@ -27,7 +27,6 @@ DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '10.0.0.233']
|
||||
|
||||
|
||||
# Application definition
|
||||
INSTALLED_APPS = [
|
||||
'jet.dashboard',
|
||||
@@ -45,14 +44,14 @@ INSTALLED_APPS = [
|
||||
'martor',
|
||||
'sass_processor',
|
||||
'formtools',
|
||||
'nested_admin',
|
||||
|
||||
# AxioDL modules
|
||||
'pages',
|
||||
'accounts',
|
||||
'boards',
|
||||
'core.apps.CoreConfig',
|
||||
'accounts.apps.AccountsConfig',
|
||||
'boards.apps.BoardsConfig',
|
||||
]
|
||||
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
@@ -63,13 +62,16 @@ MIDDLEWARE = [
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'www.urls'
|
||||
ROOT_URLCONF = 'axiodl.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [
|
||||
os.path.join(BASE_DIR, 'boards/../www/../www/templates')
|
||||
os.path.join(BASE_DIR, 'core/templates/'),
|
||||
os.path.join(BASE_DIR, 'axiodl/templates/'),
|
||||
os.path.join(BASE_DIR, 'boards/templates'),
|
||||
os.path.join(BASE_DIR, 'accounts/templates/'),
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
@@ -79,22 +81,26 @@ TEMPLATES = [
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
'libraries': {
|
||||
'site_configuration': 'axiodl.templatetags.site_configuration',
|
||||
},
|
||||
'builtins': [
|
||||
'pages.templatetags.page_extras',
|
||||
'axiodl.templatetags.site_configuration',
|
||||
'core.templatetags.core_extras',
|
||||
'core.templatetags.gravatar',
|
||||
'core.templatetags.form_tags',
|
||||
]
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'www.wsgi.application'
|
||||
|
||||
WSGI_APPLICATION = 'axiodl.wsgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
|
||||
from .database import DatabaseConfig as DATABASES
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
||||
|
||||
@@ -113,21 +119,25 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'America/Los_Angeles'
|
||||
|
||||
USE_I18N = True
|
||||
LANGUAGE_CODE = 'en'
|
||||
LANGUAGES = (
|
||||
('en', _('US English')),
|
||||
)
|
||||
|
||||
LOCALE_PATHS = (
|
||||
os.path.join(BASE_DIR, 'locale'),
|
||||
)
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
|
||||
@@ -155,25 +165,25 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
# Global martor settings
|
||||
# Input: string boolean, `true/false`
|
||||
MARTOR_ENABLE_CONFIGS = {
|
||||
'imgur': 'false', # to enable/disable imgur/custom uploader.
|
||||
'imgur': 'false', # to enable/disable imgur/custom uploader.
|
||||
'mention': 'false', # to enable/disable mention
|
||||
'jquery': 'true', # to include/revoke jquery (require for admin default django)
|
||||
'living': 'false', # to enable/disable live updates in preview
|
||||
'jquery': 'true', # to include/revoke jquery (require for admin default django)
|
||||
'living': 'false', # to enable/disable live updates in preview
|
||||
}
|
||||
|
||||
# To setup the martor editor with label or not (default is False)
|
||||
MARTOR_ENABLE_LABEL = True
|
||||
|
||||
# Imgur API Keys
|
||||
#MARTOR_IMGUR_CLIENT_ID = 'your-client-id'
|
||||
#MARTOR_IMGUR_API_KEY = 'your-api-key'
|
||||
# MARTOR_IMGUR_CLIENT_ID = 'your-client-id'
|
||||
# MARTOR_IMGUR_API_KEY = 'your-api-key'
|
||||
|
||||
# Safe Mode
|
||||
MARTOR_MARKDOWN_SAFE_MODE = True # default
|
||||
MARTOR_MARKDOWN_SAFE_MODE = True # default
|
||||
|
||||
# Markdownify
|
||||
MARTOR_MARKDOWNIFY_FUNCTION = 'martor.utils.markdownify' # default
|
||||
MARTOR_MARKDOWNIFY_URL = '/martor/markdownify/' # default
|
||||
MARTOR_MARKDOWNIFY_FUNCTION = 'martor.utils.markdownify' # default
|
||||
MARTOR_MARKDOWNIFY_URL = '/martor/markdownify/' # default
|
||||
|
||||
# Markdown extensions (default)
|
||||
MARTOR_MARKDOWN_EXTENSIONS = [
|
||||
@@ -184,23 +194,21 @@ MARTOR_MARKDOWN_EXTENSIONS = [
|
||||
|
||||
# Custom markdown extensions.
|
||||
'martor.extensions.urlize',
|
||||
'martor.extensions.del_ins', # ~~strikethrough~~ and ++underscores++
|
||||
'martor.extensions.mention', # to parse markdown mention
|
||||
'martor.extensions.emoji', # to parse markdown emoji
|
||||
'martor.extensions.del_ins', # ~~strikethrough~~ and ++underscores++
|
||||
'martor.extensions.mention', # to parse markdown mention
|
||||
'martor.extensions.emoji', # to parse markdown emoji
|
||||
'martor.extensions.mdx_video', # to parse embed/iframe video
|
||||
]
|
||||
|
||||
# Markdown Extensions Configs
|
||||
#MARTOR_MARKDOWN_EXTENSION_CONFIGS = {}
|
||||
# MARTOR_MARKDOWN_EXTENSION_CONFIGS = {}
|
||||
|
||||
# Markdown urls
|
||||
MARTOR_UPLOAD_URL = '/martor/uploader/' # default
|
||||
MARTOR_SEARCH_USERS_URL = '/martor/search-user/' # default
|
||||
MARTOR_UPLOAD_URL = '/martor/uploader/' # default
|
||||
MARTOR_SEARCH_USERS_URL = '/martor/search-user/' # default
|
||||
|
||||
# Markdown Extensions
|
||||
# MARTOR_MARKDOWN_BASE_EMOJI_URL = 'https://www.webfx.com/tools/emoji-cheat-sheet/graphics/emojis/' # from webfx
|
||||
MARTOR_MARKDOWN_BASE_EMOJI_URL = 'https://github.githubassets.com/images/icons/emoji/' # default from github
|
||||
#MARTOR_MARKDOWN_BASE_MENTION_URL = 'http://localhost/author/'
|
||||
#AUTH_USER_MODEL = 'accounts.AccountUser'
|
||||
|
||||
|
||||
MARTOR_MARKDOWN_BASE_EMOJI_URL = 'https://github.githubassets.com/images/icons/emoji/' # default from github
|
||||
# MARTOR_MARKDOWN_BASE_MENTION_URL = 'http://localhost/author/'
|
||||
# AUTH_USER_MODEL = 'accounts.AccountUser'
|
||||
@@ -0,0 +1,15 @@
|
||||
class Configuration:
|
||||
site_name = 'AxioDL'
|
||||
site_slogan = 'We reverse things others won\'t!'
|
||||
locked = False
|
||||
|
||||
|
||||
configuration = Configuration
|
||||
|
||||
|
||||
def lock_site(locked=False):
|
||||
configuration.locked = locked
|
||||
|
||||
|
||||
def is_site_locked():
|
||||
return configuration.locked
|
||||
@@ -0,0 +1,18 @@
|
||||
from django import template
|
||||
from axiodl import sitesettings
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def is_site_locked():
|
||||
return sitesettings.is_site_locked()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def get_site_name():
|
||||
return sitesettings.configuration.site_name
|
||||
|
||||
@register.simple_tag
|
||||
def get_site_slogan():
|
||||
return sitesettings.configuration.site_slogan
|
||||
@@ -1,4 +1,4 @@
|
||||
"""www URL Configuration
|
||||
"""axiodl URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
||||
@@ -20,13 +20,15 @@ from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
urlpatterns = [
|
||||
path('', include('pages.urls')),
|
||||
path('', include('core.urls')),
|
||||
url(r'^boards/', include('boards.urls')),
|
||||
url(r'^account/', include('accounts.urls')),
|
||||
url(r'^jet/', include('jet.urls', 'jet')), # Django JET URLS
|
||||
url(r'^jet/dashboard/', include('jet.dashboard.urls', 'jet-dashboard')), # Django JET dashboard URLS
|
||||
url(r'^admin/', admin.site.urls),
|
||||
path('martor/', include('martor.urls')),
|
||||
url(r'^martor/', include('martor.urls')),
|
||||
url(r'^nested_admin/', include('nested_admin.urls')),
|
||||
url(r'^i18n/', include('django.conf.urls.i18n')),
|
||||
]
|
||||
|
||||
admin.site.site_header = 'AxioDL Admin'
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
WSGI config for www project.
|
||||
WSGI config for axiodl project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
@@ -11,6 +11,6 @@ import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'www.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'axiodl.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
+24
-5
@@ -1,17 +1,36 @@
|
||||
from django.contrib import admin
|
||||
from .models import Board, Category
|
||||
from .forms import BoardForm
|
||||
import nested_admin
|
||||
from .models import Board, Category, Topic, Post
|
||||
|
||||
|
||||
class BoardInline(admin.TabularInline):
|
||||
class BoardInline(nested_admin.NestedStackedInline):
|
||||
model = Board
|
||||
verbose_name = 'Child Board'
|
||||
verbose_name_plural = 'Child Boards'
|
||||
|
||||
|
||||
class PostInline(nested_admin.NestedStackedInline):
|
||||
model = Post
|
||||
verbose_name = 'Topic'
|
||||
verbose_name_plural = 'Topics'
|
||||
|
||||
|
||||
class TopicsInline(nested_admin.NestedStackedInline):
|
||||
model = Topic
|
||||
verbose_name = 'Topic'
|
||||
verbose_name_plural = 'Topics'
|
||||
inlines = (PostInline, )
|
||||
|
||||
|
||||
@admin.register(Board)
|
||||
class BoardAdmin(admin.ModelAdmin):
|
||||
pass
|
||||
class BoardAdmin(nested_admin.NestedModelAdmin):
|
||||
inlines = (BoardInline, TopicsInline,)
|
||||
list_display = ('name',
|
||||
'description',
|
||||
'category',
|
||||
'parent',)
|
||||
list_select_related = ('category',
|
||||
'parent',)
|
||||
|
||||
|
||||
@admin.register(Category)
|
||||
|
||||
@@ -3,3 +3,4 @@ from django.apps import AppConfig
|
||||
|
||||
class BoardsConfig(AppConfig):
|
||||
name = 'boards'
|
||||
verbose_name = 'AxioDL - Boards'
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
from django.contrib import admin
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls import path
|
||||
from .models import Page, Link
|
||||
from .forms.PageForm import PageFormAdmin
|
||||
|
||||
fields = ['image_tag']
|
||||
|
||||
|
||||
@admin.register(Link)
|
||||
class MyModelAdmin(admin.ModelAdmin):
|
||||
def get_urls(self):
|
||||
urls = super().get_urls()
|
||||
my_urls = [
|
||||
path('my_view/', self.my_view),
|
||||
]
|
||||
return my_urls + urls
|
||||
|
||||
def my_view(self, request):
|
||||
# ...
|
||||
context = dict(
|
||||
# Include common variables for rendering the admin template.
|
||||
self.admin_site.each_context(request),
|
||||
)
|
||||
return TemplateResponse(request, "admin/preferences/preferences.html", context)
|
||||
|
||||
|
||||
admin.site.register(Page, PageFormAdmin)
|
||||
#admin.site.register(Link)
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
name = 'core'
|
||||
verbose_name = 'AxioDL'
|
||||
@@ -3,16 +3,16 @@
|
||||
name: Content Creator
|
||||
permissions:
|
||||
- - add_page
|
||||
- pages
|
||||
- core
|
||||
- page
|
||||
- - change_page
|
||||
- pages
|
||||
- core
|
||||
- page
|
||||
- - delete_page
|
||||
- pages
|
||||
- core
|
||||
- page
|
||||
- - view_page
|
||||
- pages
|
||||
- core
|
||||
- page
|
||||
- model: auth.group
|
||||
fields:
|
||||
@@ -32,7 +32,7 @@
|
||||
date_joined: 2019-01-01 00:00
|
||||
groups: []
|
||||
user_permissions: []
|
||||
- model: pages.page
|
||||
- model: core.page
|
||||
fields:
|
||||
page_name: 'Welcome!'
|
||||
description: 'Welcome to AxioDL!'
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.core.management import BaseCommand, call_command, load_command_class
|
||||
from django.core.management import BaseCommand, call_command
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ class Command(BaseCommand):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
call_command('migrate')
|
||||
call_command('loaddata', 'page_initial', 'board_initial')
|
||||
call_command('loaddata', 'core_initial', 'board_initial')
|
||||
|
||||
admin = User.objects.get(username='admin')
|
||||
if admin and admin.password == 'password':
|
||||
print('Found admin with unhashed, hasing password...')
|
||||
print('Found admin with unhashed, hashing password...')
|
||||
admin.set_password(admin.password)
|
||||
admin.save()
|
||||
print('Done!')
|
||||
@@ -4,7 +4,7 @@ from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import martor.models
|
||||
import www.fields
|
||||
import axiodl.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@@ -23,7 +23,7 @@ class Migration(migrations.Migration):
|
||||
('page_name', models.CharField(max_length=100)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(blank=True, null=True)),
|
||||
('is_mainpage', www.fields.UniqueBooleanField(verbose_name='Main Page')),
|
||||
('is_mainpage', axiodl.fields.UniqueBooleanField(verbose_name='Main Page')),
|
||||
('hidden', models.BooleanField(blank=True, default=False)),
|
||||
('description', models.CharField(max_length=200)),
|
||||
('content', martor.models.MartorField(blank=True, null=True)),
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user