Skip to content

Commit

Permalink
add text editing
Browse files Browse the repository at this point in the history
  • Loading branch information
gothack329 committed Feb 23, 2018
1 parent e7a4ae8 commit 254bed3
Show file tree
Hide file tree
Showing 102 changed files with 1,219 additions and 0 deletions.
Binary file modified article/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added article/__pycache__/adminx.cpython-36.pyc
Binary file not shown.
Binary file modified article/__pycache__/models.cpython-36.pyc
Binary file not shown.
5 changes: 5 additions & 0 deletions article/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from django.contrib import admin
from article.models import *

# Register your models here.
class ArticleAdmin(admin.ModelAdmin):
list_display = ('id','title','author','publish_date','visible')

admin.site.register(Article,ArticleAdmin)
54 changes: 54 additions & 0 deletions article/adminx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#-*- coding:UTF-8 -*-
from article.models import *
import xadmin
from xadmin import views
from xadmin.layout import Main, TabHolder, Tab, Fieldset, Row, Col, AppendedText, Side
from xadmin.plugins.inline import Inline
from xadmin.plugins.batch import BatchChangeAction


class MainDashboard(object):
widgets = [
[
{"type": "html", "title": "Notice", "content": "<h3> Welcome to Xadmin! </h3><p>this is html text</p>"},
# {"type": "chart", "model": "app.accessrecord", 'chart': 'user_count', 'params': {'_p_date__gte': '2013-01-08', 'p': 1, '_p_date__lt': '2013-01-29'}},
{"type": "list", "model": "cmdb.device", 'params': {'o':'-uptime'}},
],
[
{"type": "qbutton", "title": "Quick Start", "btns": [{'model': Article}, {'model':Article}, {'title': "Google", 'url': "http://www.google.com"}]},
{"type": "addform", "model": Article},
]
]
xadmin.site.register(views.website.IndexView, MainDashboard)


class BaseSetting(object):
enable_themes = True
use_bootswatch = True
xadmin.site.register(views.BaseAdminView, BaseSetting)


class GlobalSetting(object):
#global_search_models = [Host, IDC]
# global_models_icon = {
# MemoStaff:'fa fa-user'
# }
menu_style = 'accordion'
site_title = '物志'
# def get_site_menu(self):
# return ({'title':'友情链接', 'menus':(
# {'title':'百度','url':'test'},
# )},
# )
xadmin.site.register(views.CommAdminView, GlobalSetting)

class ArticleAdminx(object):
list_display = ('id','title','author','publish_date')
list_display_links = ('title',)
list_editable = ['tag']

search_fields = ['title','detail','tag']
relfield_style = 'fk-ajax'
reversion_enable = True
xadmin.site.register(Article,ArticleAdminx)

31 changes: 31 additions & 0 deletions article/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 2.0.2 on 2018-02-23 14:08

from django.db import migrations, models
import tinymce.models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Article',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('author', models.CharField(default='小志', max_length=128)),
('publish_date', models.DateTimeField(auto_now_add=True)),
('title', models.CharField(max_length=1024)),
('detail', tinymce.models.HTMLField()),
('tag', models.CharField(blank=True, max_length=128, null=True)),
('readtime', models.IntegerField(default=0)),
],
options={
'db_table': 'articles',
'ordering': ['-publish_date'],
},
),
]
18 changes: 18 additions & 0 deletions article/migrations/0002_article_visible.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.0.2 on 2018-02-23 14:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('article', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='article',
name='visible',
field=models.CharField(choices=[('Y', '是'), ('N', '否')], default='N', max_length=64),
),
]
Binary file not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions article/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# coding=utf-8
from django.db import models
from tinymce.models import HTMLField
#from tagging.fields import TagField
#from tagging.models import Tag

# Create your models here.

class Article(models.Model):
id=models.AutoField(primary_key=True)
#catalog=models.ForeignKey(Catalogs)
author = models.CharField(max_length=128,default='小志')
publish_date = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=1024)
detail = HTMLField()
tag = models.CharField(max_length=128, blank=True, null=True)
visible = models.CharField(choices=((u'Y',u'是'),(u'N',u'否')),max_length=64,default='N')
readtime = models.IntegerField(default=0)

def set_tags(self, tags):
Tag.objects.update_tags(self, tags)
def get_tags(self, tags):
return Tag.objects.get_for_object(self)
def __unicode__(self):
return self.title
class Meta:
db_table ="articles"
ordering = ['-publish_date']

Binary file modified db.sqlite3
Binary file not shown.
Binary file modified edconline/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file modified edconline/__pycache__/urls.cpython-36.pyc
Binary file not shown.
35 changes: 35 additions & 0 deletions edconline/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
'crispy_forms',
'reversion',

'tinymce',

'article',
]

Expand Down Expand Up @@ -130,3 +132,36 @@

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'/static/')


TINYMCE_DEFAULT_CONFIG = {
'height': 360,
'width': 1120,
'cleanup_on_startup': True,
'custom_undo_redo_levels': 20,
'selector': 'textarea',
'theme': 'modern',
'plugins': '''
textcolor save link image media preview codesample contextmenu
table code lists fullscreen insertdatetime nonbreaking
contextmenu directionality searchreplace wordcount visualblocks
visualchars code fullscreen autolink lists charmap print hr
anchor pagebreak
''',
'toolbar1': '''
fullscreen preview bold italic underline | fontselect,
fontsizeselect | forecolor backcolor | alignleft alignright |
aligncenter alignjustify | indent outdent | bullist numlist table |
| link image media | codesample |
''',
'toolbar2': '''
visualblocks visualchars |
charmap hr pagebreak nonbreaking anchor | code |
''',
'contextmenu': 'formats | link image',
'menubar': True,
'statusbar': True,
}

TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True
2 changes: 2 additions & 0 deletions edconline/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import xadmin
from xadmin.plugins import xversion
import article
import tinymce

admin.autodiscover()

Expand All @@ -28,5 +29,6 @@
urlpatterns = [
path('admin/', admin.site.urls),
path(r'xadmin/', xadmin.site.urls),
path(r'tinymce/', include('tinymce.urls')),
path(r'article/', include('article.urls')),
]
1 change: 1 addition & 0 deletions static/tinymce/jquery.tinymce.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions static/tinymce/langs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is where language files should be placed.

Please DO NOT translate these directly use this service: https://www.transifex.com/projects/p/tinymce/
Loading

0 comments on commit 254bed3

Please sign in to comment.