diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index 4171a39..6505c5c 100644 Binary files a/article/__pycache__/models.cpython-36.pyc and b/article/__pycache__/models.cpython-36.pyc differ diff --git a/article/__pycache__/urls.cpython-36.pyc b/article/__pycache__/urls.cpython-36.pyc index febf41e..4cc21fa 100644 Binary files a/article/__pycache__/urls.cpython-36.pyc and b/article/__pycache__/urls.cpython-36.pyc differ diff --git a/article/__pycache__/views.cpython-36.pyc b/article/__pycache__/views.cpython-36.pyc index c7564ac..c630eda 100644 Binary files a/article/__pycache__/views.cpython-36.pyc and b/article/__pycache__/views.cpython-36.pyc differ diff --git a/article/models.py b/article/models.py index 682ae7a..347fb3e 100644 --- a/article/models.py +++ b/article/models.py @@ -2,7 +2,7 @@ from django.db import models from tinymce.models import HTMLField,TinyMCE from django.contrib.auth.models import User -from django.forms import ModelForm,Textarea +from django.forms import * from userpage.models import * #from django.conf import settings #from tagging.fields import TagField @@ -50,9 +50,15 @@ class Meta: class ArticleForm(ModelForm): class Meta: model = Article - fields = ['title','author','section','tag','cover','detail'] + fields = ['title','author','author_id','section','tag','cover','detail'] widgets = { - 'detail':TinyMCE(attrs={'cols':'100%','rows':50}), + 'detail':TinyMCE(attrs={'cols':'100%','rows':30}), + 'cover':ClearableFileInput(attrs={'style':'width:50%','class':'form-control','placeholder':"封面"}), + 'tag':TextInput(attrs={'class':'form-control','placeholder':"添加标签,回车确认",'data-role':'tagsinput'}), + 'author':TextInput(attrs={'class':'form-control','placeholder':"署名"}), + 'title':TextInput(attrs={'style':'width:50%','class':'form-control','placeholder':"标题"}), + 'section':widgets.Select(choices=Section.objects.values_list('id','name'),attrs={'class':'form-control','placeholder':"标题"}), + } @@ -62,7 +68,7 @@ class Comment(models.Model): user = models.ForeignKey(Profile,on_delete=models.CASCADE,default=0) comment_time = models.DateTimeField(auto_now_add=True,editable=False) comment = HTMLField() - ip = models.GenericIPAddressField() + ip = models.GenericIPAddressField(blank=True,null=True,default='0.0.0.0') clickcount = models.IntegerField(default=0) refer = models.CharField(max_length=5096,default='none') agent = models.CharField(max_length=5096,default='none') diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index ef1c5d0..c962ae4 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -34,30 +34,37 @@

{% if art %}{{art.title}}{% endif %}

{% block content %}
- 作者: {{art.author}} + 作者: {{art.author}}           阅读数:{{art.readtime}}           评论数:{{comments|length}}           发表于:{{art.publish_time}} - + {% ifequal request.user.id art.author_id.id %} + + {% else %} + {{request.user.id}},{{art.author_id.id}} + {% endifequal %} +

+ 标签:{{art.tag}} +

广告位

{{art.detail|safe|escape }}
-

评论

+

评论

{% for i in comments %}
-
+
{{i.user}}
 {{i.comment_time}} - # {{forloop.counter}} - + # {{forloop.counter}} + Reply

@@ -69,6 +76,8 @@

{% if art %}{{art.title}}{% endif %}

+

发布评论

+ {% if messages %}
    {% for message in messages %} @@ -76,12 +85,13 @@

    {% if art %}{{art.title}}{% endif %}

    {% endfor %}
{% endif %} -
+ {% csrf_token %} {{comment_form.comment}} - +

+
diff --git a/article/templates/article/publish.html b/article/templates/article/publish.html index c145a41..efb2df1 100644 --- a/article/templates/article/publish.html +++ b/article/templates/article/publish.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block header %} -{{art.title}} - 物志 +发布文章 - 物志 - + + {% endblock %} - {% block banner %} -'); + this.$input = $('').appendTo(this.$container); + + this.$element.before(this.$container); + + this.build(options); + this.isInit = false; + } + + TagsInput.prototype = { + constructor: TagsInput, + + /** + * Adds the given item as a new tag. Pass true to dontPushVal to prevent + * updating the elements val() + */ + add: function(item, dontPushVal, options) { + var self = this; + + if (self.options.maxTags && self.itemsArray.length >= self.options.maxTags) + return; + + // Ignore falsey values, except false + if (item !== false && !item) + return; + + // Trim value + if (typeof item === "string" && self.options.trimValue) { + item = $.trim(item); + } + + // Throw an error when trying to add an object while the itemValue option was not set + if (typeof item === "object" && !self.objectItems) + throw("Can't add objects when itemValue option is not set"); + + // Ignore strings only containg whitespace + if (item.toString().match(/^\s*$/)) + return; + + // If SELECT but not multiple, remove current tag + if (self.isSelect && !self.multiple && self.itemsArray.length > 0) + self.remove(self.itemsArray[0]); + + if (typeof item === "string" && this.$element[0].tagName === 'INPUT') { + var delimiter = (self.options.delimiterRegex) ? self.options.delimiterRegex : self.options.delimiter; + var items = item.split(delimiter); + if (items.length > 1) { + for (var i = 0; i < items.length; i++) { + this.add(items[i], true); + } + + if (!dontPushVal) + self.pushVal(self.options.triggerChange); + return; + } + } + + var itemValue = self.options.itemValue(item), + itemText = self.options.itemText(item), + tagClass = self.options.tagClass(item), + itemTitle = self.options.itemTitle(item); + + // Ignore items allready added + var existing = $.grep(self.itemsArray, function(item) { return self.options.itemValue(item) === itemValue; } )[0]; + if (existing && !self.options.allowDuplicates) { + // Invoke onTagExists + if (self.options.onTagExists) { + var $existingTag = $(".tag", self.$container).filter(function() { return $(this).data("item") === existing; }); + self.options.onTagExists(item, $existingTag); + } + return; + } + + // if length greater than limit + if (self.items().toString().length + item.length + 1 > self.options.maxInputLength) + return; + + // raise beforeItemAdd arg + var beforeItemAddEvent = $.Event('beforeItemAdd', { item: item, cancel: false, options: options}); + self.$element.trigger(beforeItemAddEvent); + if (beforeItemAddEvent.cancel) + return; + + // register item in internal array and map + self.itemsArray.push(item); + + // add a tag element + + var $tag = $('' + htmlEncode(itemText) + ''); + $tag.data('item', item); + self.findInputWrapper().before($tag); + $tag.after(' '); + + // Check to see if the tag exists in its raw or uri-encoded form + var optionExists = ( + $('option[value="' + encodeURIComponent(itemValue) + '"]', self.$element).length || + $('option[value="' + htmlEncode(itemValue) + '"]', self.$element).length + ); + + // add