Skip to content

Commit e7a4178

Browse files
author
差沙
committed
Init commit
0 parents  commit e7a4178

File tree

576 files changed

+67886
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+67886
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
xadmin-cms
2+
==========
3+
4+
Xcms 是 ``django-xadmin`` 的一套插件集, 包含制作 cms 系统需要的常用插件:
5+
6+
1. 可见即可得编辑器
7+
8+
2. 树形组件
9+
10+
使用方法
11+
--------
12+
13+
在 django settings 中的 INSTALL_APPS 加入 ``xcms`` 即可

demo_app/app/__init__.py

Whitespace-only changes.

demo_app/app/models.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#coding:utf-8
2+
from django.db import models
3+
4+
class Category(models.Model):
5+
name = models.CharField(u"名称", max_length=64)
6+
parent = models.ForeignKey('self', verbose_name=u'父类别', related_name='children', null=True, blank=True)
7+
8+
class Meta:
9+
verbose_name=u'类别'
10+
verbose_name_plural = verbose_name
11+
12+
def __unicode__(self):
13+
return self.name
14+
15+
class Article(models.Model):
16+
title = models.CharField(u"标题", max_length=200)
17+
date = models.DateField(u"发布时间")
18+
content = models.TextField(u"内容", null=True, blank=True)
19+
categories = models.ManyToManyField('Category', null=True, blank=True)
20+
21+
class Meta:
22+
verbose_name=u'文章'
23+
verbose_name_plural = verbose_name
24+
25+
def __unicode__(self):
26+
return self.title

demo_app/app/xadmin.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#coding:utf-8
2+
import exadmin
3+
from exadmin.layout import Fieldset, Field
4+
from exadmin.views.base import CommAdminView
5+
6+
from models import Article, Category
7+
8+
class GolbeSetting(object):
9+
globe_search_models = [Article, ]
10+
globe_models_icon = {
11+
Article: 'file', Category: 'cloud'
12+
}
13+
exadmin.site.register(CommAdminView, GolbeSetting)
14+
15+
class ArticleAdmin(object):
16+
list_display = ('title', 'categories', 'date')
17+
list_display_links = ('title',)
18+
19+
search_fields = ('title', 'content')
20+
list_editable = ('date',)
21+
list_filter = ('categories', 'date')
22+
23+
form_layout = (
24+
Fieldset('基本信息',
25+
'title', 'date'
26+
),
27+
Fieldset('文章内容',
28+
Field('content', template="xcms/content_field.html")
29+
),
30+
)
31+
style_fields = {'content': 'wysi_ck', 'categories':'m2m_tree'}
32+
33+
class CategoryAdmin(object):
34+
list_display = ('name', 'parent')
35+
list_display_links = ('id', 'name',)
36+
37+
search_fields = ('name', )
38+
list_editable = ('name', )
39+
list_filter = ('parent', )
40+
41+
exadmin.site.register(Article, ArticleAdmin)
42+
exadmin.site.register(Category, CategoryAdmin)

demo_app/data.db

324 KB
Binary file not shown.

demo_app/data.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

demo_app/extest/__init__.py

Whitespace-only changes.

demo_app/extest/settings.py

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Django settings for wictrl project.
2+
3+
import sys
4+
import os.path
5+
6+
reload(sys)
7+
sys.setdefaultencoding('utf-8')
8+
9+
PROJECT_ROOT = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir)
10+
11+
DEBUG = True
12+
TEMPLATE_DEBUG = DEBUG
13+
14+
ADMINS = (
15+
# ('Your Name', '[email protected]'),
16+
)
17+
18+
MANAGERS = ADMINS
19+
20+
DATABASES = {
21+
'default': {
22+
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
23+
'NAME': os.path.join(PROJECT_ROOT, 'data.db'), # Or path to database file if using sqlite3.
24+
'USER': '', # Not used with sqlite3.
25+
'PASSWORD': '', # Not used with sqlite3.
26+
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
27+
'PORT': '', # Set to empty string for default. Not used with sqlite3.
28+
}
29+
}
30+
try:
31+
import dj_database_url
32+
DATABASES['default'] = dj_database_url.config()
33+
except Exception:
34+
pass
35+
# Local time zone for this installation. Choices can be found here:
36+
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
37+
# although not all choices may be available on all operating systems.
38+
# In a Windows environment this must be set to your system time zone.
39+
TIME_ZONE = 'America/Chicago'
40+
41+
# Language code for this installation. All choices can be found here:
42+
# http://www.i18nguy.com/unicode/language-identifiers.html
43+
LANGUAGE_CODE = 'en-us'
44+
45+
SITE_ID = 1
46+
47+
# If you set this to False, Django will make some optimizations so as not
48+
# to load the internationalization machinery.
49+
USE_I18N = True
50+
51+
# If you set this to False, Django will not format dates, numbers and
52+
# calendars according to the current locale.
53+
USE_L10N = True
54+
55+
# If you set this to False, Django will not use timezone-aware datetimes.
56+
USE_TZ = True
57+
58+
# Absolute filesystem path to the directory that will hold user-uploaded files.
59+
# Example: "/home/media/media.lawrence.com/media/"
60+
MEDIA_ROOT = ''
61+
62+
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
63+
# trailing slash.
64+
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
65+
MEDIA_URL = ''
66+
67+
# Absolute path to the directory static files should be collected to.
68+
# Don't put anything in this directory yourself; store your static files
69+
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
70+
# Example: "/home/media/media.lawrence.com/static/"
71+
STATIC_ROOT = 'static/'
72+
73+
# URL prefix for static files.
74+
# Example: "http://media.lawrence.com/static/"
75+
STATIC_URL = '/static/'
76+
77+
# Additional locations of static files
78+
STATICFILES_DIRS = (
79+
# Put strings here, like "/home/html/static" or "C:/www/django/static".
80+
# Always use forward slashes, even on Windows.
81+
# Don't forget to use absolute paths, not relative paths.
82+
)
83+
84+
# List of finder classes that know how to find static files in
85+
# various locations.
86+
STATICFILES_FINDERS = (
87+
'django.contrib.staticfiles.finders.FileSystemFinder',
88+
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
89+
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
90+
)
91+
92+
# Make this unique, and don't share it with anybody.
93+
SECRET_KEY = '5=!nss_+^nvyyc_j(tdcf!7(_una*3gtw+_8v5jaa=)j0g^d_2'
94+
95+
# List of callables that know how to import templates from various sources.
96+
TEMPLATE_LOADERS = (
97+
'django.template.loaders.filesystem.Loader',
98+
'django.template.loaders.app_directories.Loader',
99+
# 'django.template.loaders.eggs.Loader',
100+
)
101+
102+
MIDDLEWARE_CLASSES = (
103+
'django.middleware.common.CommonMiddleware',
104+
'django.contrib.sessions.middleware.SessionMiddleware',
105+
'django.middleware.csrf.CsrfViewMiddleware',
106+
'django.contrib.auth.middleware.AuthenticationMiddleware',
107+
'django.contrib.messages.middleware.MessageMiddleware',
108+
# Uncomment the next line for simple clickjacking protection:
109+
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
110+
)
111+
112+
ROOT_URLCONF = 'extest.urls'
113+
114+
# Python dotted path to the WSGI application used by Django's runserver.
115+
WSGI_APPLICATION = 'extest.wsgi.application'
116+
117+
TEMPLATE_DIRS = (
118+
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
119+
# Always use forward slashes, even on Windows.
120+
# Don't forget to use absolute paths, not relative paths.
121+
os.path.join(PROJECT_ROOT, "templates"),
122+
)
123+
124+
INSTALLED_APPS = (
125+
'django.contrib.auth',
126+
'django.contrib.contenttypes',
127+
'django.contrib.sessions',
128+
'django.contrib.messages',
129+
'django.contrib.staticfiles',
130+
131+
'exadmin',
132+
'crispy_forms',
133+
'reversion',
134+
135+
'app',
136+
)
137+
138+
DATE_FORMAT = 'Y-m-d'
139+
DATETIME_FORMAT = 'Y-m-d H:i'
140+
TIME_FORMAT = 'H:i'
141+
142+
# A sample logging configuration. The only tangible logging
143+
# performed by this configuration is to send an email to
144+
# the site admins on every HTTP 500 error when DEBUG=False.
145+
# See http://docs.djangoproject.com/en/dev/topics/logging for
146+
# more details on how to customize your logging configuration.
147+
LOGGING = {
148+
'version': 1,
149+
'disable_existing_loggers': False,
150+
'filters': {
151+
'require_debug_false': {
152+
'()': 'django.utils.log.RequireDebugFalse'
153+
}
154+
},
155+
'handlers': {
156+
'mail_admins': {
157+
'level': 'ERROR',
158+
'filters': ['require_debug_false'],
159+
'class': 'django.utils.log.AdminEmailHandler'
160+
},
161+
'console':{
162+
'level': 'DEBUG',
163+
'class': 'logging.StreamHandler'
164+
},
165+
},
166+
'loggers': {
167+
'django.request': {
168+
'handlers': ['mail_admins'],
169+
'level': 'ERROR',
170+
'propagate': True,
171+
},
172+
# 'django.db.backends': {
173+
# 'handlers': ['console'],
174+
# 'level': 'DEBUG',
175+
# }
176+
}
177+
}

demo_app/extest/urls.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.conf.urls import patterns, include, url
2+
3+
# Uncomment the next two lines to enable the admin:
4+
import exadmin
5+
exadmin.autodiscover()
6+
7+
from exadmin.plugins import xversion
8+
xversion.registe_models()
9+
10+
urlpatterns = patterns('',
11+
url(r'', include(exadmin.site.urls)),
12+
)

demo_app/extest/wsgi.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
WSGI config for wictrl project.
3+
4+
This module contains the WSGI application used by Django's development server
5+
and any production WSGI deployments. It should expose a module-level variable
6+
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
7+
this application via the ``WSGI_APPLICATION`` setting.
8+
9+
Usually you will have the standard Django WSGI application here, but it also
10+
might make sense to replace the whole Django WSGI application with a custom one
11+
that later delegates to the Django one. For example, you could introduce WSGI
12+
middleware here, or combine a Django application with an application of another
13+
framework.
14+
15+
"""
16+
import os
17+
18+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wictrl.settings")
19+
20+
# This application object is used by any WSGI server configured to use this
21+
# file. This includes Django's development server, if the WSGI_APPLICATION
22+
# setting points here.
23+
from django.core.wsgi import get_wsgi_application
24+
application = get_wsgi_application()
25+
26+
# Apply WSGI middleware here.
27+
# from helloworld.wsgi import HelloWorldApplication
28+
# application = HelloWorldApplication(application)

0 commit comments

Comments
 (0)