diff --git a/article/__pycache__/models.cpython-36.pyc b/article/__pycache__/models.cpython-36.pyc index 6505c5c..f95925a 100644 Binary files a/article/__pycache__/models.cpython-36.pyc and b/article/__pycache__/models.cpython-36.pyc differ diff --git a/article/__pycache__/views.cpython-36.pyc b/article/__pycache__/views.cpython-36.pyc index c630eda..b4d040d 100644 Binary files a/article/__pycache__/views.cpython-36.pyc and b/article/__pycache__/views.cpython-36.pyc differ diff --git a/article/migrations/0014_auto_20180228_1552.py b/article/migrations/0014_auto_20180228_1552.py new file mode 100644 index 0000000..96016b2 --- /dev/null +++ b/article/migrations/0014_auto_20180228_1552.py @@ -0,0 +1,18 @@ +# Generated by Django 2.0.2 on 2018-02-28 07:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('article', '0013_auto_20180226_1938'), + ] + + operations = [ + migrations.AlterField( + model_name='comment', + name='ip', + field=models.GenericIPAddressField(blank=True, default='0.0.0.0', null=True), + ), + ] diff --git a/article/migrations/__pycache__/0014_auto_20180228_1552.cpython-36.pyc b/article/migrations/__pycache__/0014_auto_20180228_1552.cpython-36.pyc new file mode 100644 index 0000000..31b2f36 Binary files /dev/null and b/article/migrations/__pycache__/0014_auto_20180228_1552.cpython-36.pyc differ diff --git a/article/models.py b/article/models.py index 347fb3e..c70247b 100644 --- a/article/models.py +++ b/article/models.py @@ -51,15 +51,22 @@ class ArticleForm(ModelForm): class Meta: model = Article fields = ['title','author','author_id','section','tag','cover','detail'] + error_messages = { + 'section':{'required': '请选择主题分区'}, + 'author':{'required': '请输入作者名称'}, + 'cover':{'required': '请上传封面图'}, + 'detail':{'required': '请输入正文内容'}, + 'title':{'required': '请输入文章标题'}, + + } widgets = { - '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':"标题"}), - - } + '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':"标题"}), + } class Comment(models.Model): diff --git a/article/templates/article/detail.html b/article/templates/article/detail.html index c962ae4..64b5055 100644 --- a/article/templates/article/detail.html +++ b/article/templates/article/detail.html @@ -2,6 +2,7 @@ {% block header %} {{art.title}} - 物志 + {% endfor %} - - {% endif %} + {% endfor %} +{% endif %} +
- {% csrf_token %} - - - {{comment_form.comment}} + {% csrf_token %} + + + {{comment_form.comment}}

- +
diff --git a/article/templates/article/publish.html b/article/templates/article/publish.html index efb2df1..b74ae3c 100644 --- a/article/templates/article/publish.html +++ b/article/templates/article/publish.html @@ -21,6 +21,8 @@ + + {% endblock %} {% block banner %} @@ -33,14 +35,29 @@

{{operation}}文章

- {% if messages %} - - {% endif %} -
+ {% endfor %} +{% endif %} + + {% csrf_token %}

{{article_form.section}} - {{article_form.title}} - {{article_form.author}}

diff --git a/article/views.py b/article/views.py index 6f01e52..2869b9d 100644 --- a/article/views.py +++ b/article/views.py @@ -19,8 +19,6 @@ def detail(request, article_id): if request.method == 'POST': comment_form = CommentForm(request.POST,instance=None) - print(comment_form) - instance = comment_form.save(commit=False) instance.ip = request.META['REMOTE_ADDR'] @@ -41,17 +39,16 @@ def detail(request, article_id): def publish(request): if request.method == 'POST': - article_form = ArticleForm(request.POST,instance=None) + article_form = ArticleForm(request.POST,request.FILES,instance=None) if article_form.is_valid(): instance = article_form.save(commit=False) instance.ip = request.META['REMOTE_ADDR'] art = instance.save() - return redirect('/article/%d/' % (instance.pk,)) else: - messages.error(request, 'Please correct the error below.') + messages.error(request, article_form.errors) else: article_form = ArticleForm(instance=None) @@ -61,7 +58,7 @@ def publish(request): def update(request, article_id): art = Article.objects.get(pk=article_id) if request.method == 'POST': - article_form = ArticleForm(request.POST,instance=art) + article_form = ArticleForm(request.POST,request.FILES,instance=art) if article_form.is_valid(): instance = article_form.save(commit=False) @@ -70,7 +67,7 @@ def update(request, article_id): return redirect('/article/%d/' % (article_id,)) else: - messages.error(request, 'Please correct the error below.') + messages.error(request, article_form.errors) else: article_form = ArticleForm(instance=art) diff --git a/db.sqlite3 b/db.sqlite3 index fd9c210..fd7f9f8 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/edconline/__pycache__/globalarg.cpython-36.pyc b/edconline/__pycache__/globalarg.cpython-36.pyc index a8ec70a..1d421a5 100644 Binary files a/edconline/__pycache__/globalarg.cpython-36.pyc and b/edconline/__pycache__/globalarg.cpython-36.pyc differ diff --git a/edconline/__pycache__/settings.cpython-36.pyc b/edconline/__pycache__/settings.cpython-36.pyc index 02b7f21..649fe15 100644 Binary files a/edconline/__pycache__/settings.cpython-36.pyc and b/edconline/__pycache__/settings.cpython-36.pyc differ diff --git a/edconline/globalarg.py b/edconline/globalarg.py index de2b0b3..0e29ccf 100644 --- a/edconline/globalarg.py +++ b/edconline/globalarg.py @@ -3,5 +3,8 @@ def settings(request): - secs = Section.objects.all() - return {'secs':secs} \ No newline at end of file + if request.user.is_authenticated : + userid = request.user.id + user =Profile.objects.get(user=userid) + secs = Section.objects.all() + return {'secs':secs,'user':user} \ No newline at end of file diff --git a/edconline/settings.py b/edconline/settings.py index b3c4c55..4e0d62b 100644 --- a/edconline/settings.py +++ b/edconline/settings.py @@ -11,6 +11,7 @@ """ import os +from django.contrib.messages import constants as messages # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -139,6 +140,16 @@ ) + +MESSAGE_TAGS = { + messages.DEBUG: 'alert-info', + messages.INFO: 'alert-info', + messages.SUCCESS: 'alert-success', + messages.WARNING: 'alert-warning', + messages.ERROR: 'alert-danger', +} + + TINYMCE_DEFAULT_CONFIG = { 'height': 360, 'width': 1120, diff --git a/notification/__init__.py b/notification/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notification/admin.py b/notification/admin.py new file mode 100644 index 0000000..4e61edb --- /dev/null +++ b/notification/admin.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from .models import * + + +class MsgAdmin(admin.ModelAdmin): + list_display=('id','user','mention_user','msg_time') +admin.site.register(Msg,MsgAdmin) diff --git a/notification/apps.py b/notification/apps.py new file mode 100644 index 0000000..40b3eb9 --- /dev/null +++ b/notification/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class NotificationConfig(AppConfig): + name = 'notification' diff --git a/notification/migrations/__init__.py b/notification/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notification/models.py b/notification/models.py new file mode 100644 index 0000000..2e2b061 --- /dev/null +++ b/notification/models.py @@ -0,0 +1,19 @@ +from django.db import models +from django.contrib.auth.models import User +from django.forms import ModelForm,Textarea +from userpage.models import * +from article.models import * + +# Create your models here. + +class Msg(models.Model): + id=models.AutoField(primary_key=True) + user = models.ForeignKey(Profile, on_delete=models.CASCADE) + mention_user = models.ManyToManyField(Profile, on_delete=models.CASCADE) + comment = models.ForeignKey(Comment, on_delete=models.CASCADE) + msg_time = models.DateTimeField(auto_now_add=True,editable=False) + + def __str__(self): + return self.comments + + diff --git a/notification/tests.py b/notification/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/notification/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/notification/views.py b/notification/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/notification/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/static/bootstrap/css/style.css b/static/bootstrap/css/style.css index 1a52b93..b75578c 100755 --- a/static/bootstrap/css/style.css +++ b/static/bootstrap/css/style.css @@ -124,9 +124,6 @@ div.container-fluid { padding-bottom:30px; } -.card .comment { -} - .card .comment div { display: inline-block; margin:10px; @@ -171,6 +168,26 @@ span.floor { padding-bottom: 40px; } +.card .usercard div { + display: inline-block; + margin:10px; + float:left; +} + +.card .usercard .usercard-avatar { + margin:10px 0 0 20px; + width:80px; + height:80px; +} + +.card .usercard .usercard-info { + float:left; + padding-right:20px; +} + + + + diff --git a/static/bootstrap/js/bootstrap-notify.js b/static/bootstrap/js/bootstrap-notify.js new file mode 100644 index 0000000..2efc73b --- /dev/null +++ b/static/bootstrap/js/bootstrap-notify.js @@ -0,0 +1,350 @@ +/* +* Project: Bootstrap Notify = v3.1.3 +* Description: Turns standard Bootstrap alerts into "Growl-like" notifications. +* Author: Mouse0270 aka Robert McIntosh +* License: MIT License +* Website: https://github.com/mouse0270/bootstrap-growl +*/ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS + factory(require('jquery')); + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { + // Create the defaults once + var defaults = { + element: 'body', + position: null, + type: "info", + allow_dismiss: true, + newest_on_top: false, + showProgressbar: false, + placement: { + from: "top", + align: "right" + }, + offset: 20, + spacing: 10, + z_index: 1031, + delay: 5000, + timer: 1000, + url_target: '_blank', + mouse_over: null, + animate: { + enter: 'animated fadeInDown', + exit: 'animated fadeOutUp' + }, + onShow: null, + onShown: null, + onClose: null, + onClosed: null, + icon_type: 'class', + template: '' + }; + + String.format = function() { + var str = arguments[0]; + for (var i = 1; i < arguments.length; i++) { + str = str.replace(RegExp("\\{" + (i - 1) + "\\}", "gm"), arguments[i]); + } + return str; + }; + + function Notify ( element, content, options ) { + // Setup Content of Notify + var content = { + content: { + message: typeof content == 'object' ? content.message : content, + title: content.title ? content.title : '', + icon: content.icon ? content.icon : '', + url: content.url ? content.url : '#', + target: content.target ? content.target : '-' + } + }; + + options = $.extend(true, {}, content, options); + this.settings = $.extend(true, {}, defaults, options); + this._defaults = defaults; + if (this.settings.content.target == "-") { + this.settings.content.target = this.settings.url_target; + } + this.animations = { + start: 'webkitAnimationStart oanimationstart MSAnimationStart animationstart', + end: 'webkitAnimationEnd oanimationend MSAnimationEnd animationend' + } + + if (typeof this.settings.offset == 'number') { + this.settings.offset = { + x: this.settings.offset, + y: this.settings.offset + }; + } + + this.init(); + }; + + $.extend(Notify.prototype, { + init: function () { + var self = this; + + this.buildNotify(); + if (this.settings.content.icon) { + this.setIcon(); + } + if (this.settings.content.url != "#") { + this.styleURL(); + } + this.placement(); + this.bind(); + + this.notify = { + $ele: this.$ele, + update: function(command, update) { + var commands = {}; + if (typeof command == "string") { + commands[command] = update; + }else{ + commands = command; + } + for (var command in commands) { + switch (command) { + case "type": + this.$ele.removeClass('alert-' + self.settings.type); + this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass('progress-bar-' + self.settings.type); + self.settings.type = commands[command]; + this.$ele.addClass('alert-' + commands[command]).find('[data-notify="progressbar"] > .progress-bar').addClass('progress-bar-' + commands[command]); + break; + case "icon": + var $icon = this.$ele.find('[data-notify="icon"]'); + if (self.settings.icon_type.toLowerCase() == 'class') { + $icon.removeClass(self.settings.content.icon).addClass(commands[command]); + }else{ + if (!$icon.is('img')) { + $icon.find('img'); + } + $icon.attr('src', commands[command]); + } + break; + case "progress": + var newDelay = self.settings.delay - (self.settings.delay * (commands[command] / 100)); + this.$ele.data('notify-delay', newDelay); + this.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', commands[command]).css('width', commands[command] + '%'); + break; + case "url": + this.$ele.find('[data-notify="url"]').attr('href', commands[command]); + break; + case "target": + this.$ele.find('[data-notify="url"]').attr('target', commands[command]); + break; + default: + this.$ele.find('[data-notify="' + command +'"]').html(commands[command]); + }; + } + var posX = this.$ele.outerHeight() + parseInt(self.settings.spacing) + parseInt(self.settings.offset.y); + self.reposition(posX); + }, + close: function() { + self.close(); + } + }; + }, + buildNotify: function () { + var content = this.settings.content; + this.$ele = $(String.format(this.settings.template, this.settings.type, content.title, content.message, content.url, content.target)); + this.$ele.attr('data-notify-position', this.settings.placement.from + '-' + this.settings.placement.align); + if (!this.settings.allow_dismiss) { + this.$ele.find('[data-notify="dismiss"]').css('display', 'none'); + } + if ((this.settings.delay <= 0 && !this.settings.showProgressbar) || !this.settings.showProgressbar) { + this.$ele.find('[data-notify="progressbar"]').remove(); + } + }, + setIcon: function() { + if (this.settings.icon_type.toLowerCase() == 'class') { + this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon); + }else{ + if (this.$ele.find('[data-notify="icon"]').is('img')) { + this.$ele.find('[data-notify="icon"]').attr('src', this.settings.content.icon); + }else{ + this.$ele.find('[data-notify="icon"]').append('Notify Icon'); + } + } + }, + styleURL: function() { + this.$ele.find('[data-notify="url"]').css({ + backgroundImage: 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)', + height: '100%', + left: '0px', + position: 'absolute', + top: '0px', + width: '100%', + zIndex: this.settings.z_index + 1 + }); + this.$ele.find('[data-notify="dismiss"]').css({ + position: 'absolute', + right: '10px', + top: '5px', + zIndex: this.settings.z_index + 2 + }); + }, + placement: function() { + var self = this, + offsetAmt = this.settings.offset.y, + css = { + display: 'inline-block', + margin: '0px auto', + position: this.settings.position ? this.settings.position : (this.settings.element === 'body' ? 'fixed' : 'absolute'), + transition: 'all .5s ease-in-out', + zIndex: this.settings.z_index + }, + hasAnimation = false, + settings = this.settings; + + $('[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])').each(function() { + return offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + parseInt($(this).outerHeight()) + parseInt(settings.spacing)); + }); + if (this.settings.newest_on_top == true) { + offsetAmt = this.settings.offset.y; + } + css[this.settings.placement.from] = offsetAmt+'px'; + + switch (this.settings.placement.align) { + case "left": + case "right": + css[this.settings.placement.align] = this.settings.offset.x+'px'; + break; + case "center": + css.left = 0; + css.right = 0; + break; + } + this.$ele.css(css).addClass(this.settings.animate.enter); + $.each(Array('webkit', 'moz', 'o', 'ms', ''), function(index, prefix) { + self.$ele[0].style[prefix+'AnimationIterationCount'] = 1; + }); + + $(this.settings.element).append(this.$ele); + + if (this.settings.newest_on_top == true) { + offsetAmt = (parseInt(offsetAmt)+parseInt(this.settings.spacing)) + this.$ele.outerHeight(); + this.reposition(offsetAmt); + } + + if ($.isFunction(self.settings.onShow)) { + self.settings.onShow.call(this.$ele); + } + + this.$ele.one(this.animations.start, function(event) { + hasAnimation = true; + }).one(this.animations.end, function(event) { + if ($.isFunction(self.settings.onShown)) { + self.settings.onShown.call(this); + } + }); + + setTimeout(function() { + if (!hasAnimation) { + if ($.isFunction(self.settings.onShown)) { + self.settings.onShown.call(this); + } + } + }, 600); + }, + bind: function() { + var self = this; + + this.$ele.find('[data-notify="dismiss"]').on('click', function() { + self.close(); + }) + + this.$ele.mouseover(function(e) { + $(this).data('data-hover', "true"); + }).mouseout(function(e) { + $(this).data('data-hover', "false"); + }); + this.$ele.data('data-hover', "false"); + + if (this.settings.delay > 0) { + self.$ele.data('notify-delay', self.settings.delay); + var timer = setInterval(function() { + var delay = parseInt(self.$ele.data('notify-delay')) - self.settings.timer; + if ((self.$ele.data('data-hover') === 'false' && self.settings.mouse_over == "pause") || self.settings.mouse_over != "pause") { + var percent = ((self.settings.delay - delay) / self.settings.delay) * 100; + self.$ele.data('notify-delay', delay); + self.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', percent).css('width', percent + '%'); + } + if (delay <= -(self.settings.timer)) { + clearInterval(timer); + self.close(); + } + }, self.settings.timer); + } + }, + close: function() { + var self = this, + $successors = null, + posX = parseInt(this.$ele.css(this.settings.placement.from)), + hasAnimation = false; + + this.$ele.data('closing', 'true').addClass(this.settings.animate.exit); + self.reposition(posX); + + if ($.isFunction(self.settings.onClose)) { + self.settings.onClose.call(this.$ele); + } + + this.$ele.one(this.animations.start, function(event) { + hasAnimation = true; + }).one(this.animations.end, function(event) { + $(this).remove(); + if ($.isFunction(self.settings.onClosed)) { + self.settings.onClosed.call(this); + } + }); + + setTimeout(function() { + if (!hasAnimation) { + self.$ele.remove(); + if (self.settings.onClosed) { + self.settings.onClosed(self.$ele); + } + } + }, 600); + }, + reposition: function(posX) { + var self = this, + notifies = '[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])', + $elements = this.$ele.nextAll(notifies); + if (this.settings.newest_on_top == true) { + $elements = this.$ele.prevAll(notifies); + } + $elements.each(function() { + $(this).css(self.settings.placement.from, posX); + posX = (parseInt(posX)+parseInt(self.settings.spacing)) + $(this).outerHeight(); + }); + } + }); + + $.notify = function ( content, options ) { + var plugin = new Notify( this, content, options ); + return plugin.notify; + }; + $.notifyDefaults = function( options ) { + defaults = $.extend(true, {}, defaults, options); + return defaults; + }; + $.notifyClose = function( command ) { + if (typeof command === "undefined" || command == "all") { + $('[data-notify]').find('[data-notify="dismiss"]').trigger('click'); + }else{ + $('[data-notify-position="'+command+'"]').find('[data-notify="dismiss"]').trigger('click'); + } + }; + +})); \ No newline at end of file diff --git a/static/bootstrap/js/bootstrap-notify.min.js b/static/bootstrap/js/bootstrap-notify.min.js new file mode 100644 index 0000000..725e285 --- /dev/null +++ b/static/bootstrap/js/bootstrap-notify.min.js @@ -0,0 +1,2 @@ +/* Project: Bootstrap Growl = v3.1.3 | Description: Turns standard Bootstrap alerts into "Growl-like" notifications. | Author: Mouse0270 aka Robert McIntosh | License: MIT License | Website: https://github.com/mouse0270/bootstrap-growl */ +!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){function e(e,i,n){var i={content:{message:"object"==typeof i?i.message:i,title:i.title?i.title:"",icon:i.icon?i.icon:"",url:i.url?i.url:"#",target:i.target?i.target:"-"}};n=t.extend(!0,{},i,n),this.settings=t.extend(!0,{},s,n),this._defaults=s,"-"==this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),this.init()}var s={element:"body",position:null,type:"info",allow_dismiss:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:''};String.format=function(){for(var t=arguments[0],e=1;e .progress-bar').removeClass("progress-bar-"+t.settings.type),t.settings.type=i[e],this.$ele.addClass("alert-"+i[e]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+i[e]);break;case"icon":var n=this.$ele.find('[data-notify="icon"]');"class"==t.settings.icon_type.toLowerCase()?n.removeClass(t.settings.content.icon).addClass(i[e]):(n.is("img")||n.find("img"),n.attr("src",i[e]));break;case"progress":var a=t.settings.delay-t.settings.delay*(i[e]/100);this.$ele.data("notify-delay",a),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i[e]).css("width",i[e]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",i[e]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",i[e]);break;default:this.$ele.find('[data-notify="'+e+'"]').html(i[e])}var o=this.$ele.outerHeight()+parseInt(t.settings.spacing)+parseInt(t.settings.offset.y);t.reposition(o)},close:function(){t.close()}}},buildNotify:function(){var e=this.settings.content;this.$ele=t(String.format(this.settings.template,this.settings.type,e.title,e.message,e.url,e.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay<=0&&!this.settings.showProgressbar||!this.settings.showProgressbar)&&this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"==this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('Notify Icon')},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:"0px",position:"absolute",top:"0px",width:"100%",zIndex:this.settings.z_index+1}),this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},placement:function(){var e=this,s=this.settings.offset.y,i={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},n=!1,a=this.settings;switch(t('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){return s=Math.max(s,parseInt(t(this).css(a.placement.from))+parseInt(t(this).outerHeight())+parseInt(a.spacing))}),1==this.settings.newest_on_top&&(s=this.settings.offset.y),i[this.settings.placement.from]=s+"px",this.settings.placement.align){case"left":case"right":i[this.settings.placement.align]=this.settings.offset.x+"px";break;case"center":i.left=0,i.right=0}this.$ele.css(i).addClass(this.settings.animate.enter),t.each(Array("webkit","moz","o","ms",""),function(t,s){e.$ele[0].style[s+"AnimationIterationCount"]=1}),t(this.settings.element).append(this.$ele),1==this.settings.newest_on_top&&(s=parseInt(s)+parseInt(this.settings.spacing)+this.$ele.outerHeight(),this.reposition(s)),t.isFunction(e.settings.onShow)&&e.settings.onShow.call(this.$ele),this.$ele.one(this.animations.start,function(){n=!0}).one(this.animations.end,function(){t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)}),setTimeout(function(){n||t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)},600)},bind:function(){var e=this;if(this.$ele.find('[data-notify="dismiss"]').on("click",function(){e.close()}),this.$ele.mouseover(function(){t(this).data("data-hover","true")}).mouseout(function(){t(this).data("data-hover","false")}),this.$ele.data("data-hover","false"),this.settings.delay>0){e.$ele.data("notify-delay",e.settings.delay);var s=setInterval(function(){var t=parseInt(e.$ele.data("notify-delay"))-e.settings.timer;if("false"===e.$ele.data("data-hover")&&"pause"==e.settings.mouse_over||"pause"!=e.settings.mouse_over){var i=(e.settings.delay-t)/e.settings.delay*100;e.$ele.data("notify-delay",t),e.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i).css("width",i+"%")}t<=-e.settings.timer&&(clearInterval(s),e.close())},e.settings.timer)}},close:function(){var e=this,s=parseInt(this.$ele.css(this.settings.placement.from)),i=!1;this.$ele.data("closing","true").addClass(this.settings.animate.exit),e.reposition(s),t.isFunction(e.settings.onClose)&&e.settings.onClose.call(this.$ele),this.$ele.one(this.animations.start,function(){i=!0}).one(this.animations.end,function(){t(this).remove(),t.isFunction(e.settings.onClosed)&&e.settings.onClosed.call(this)}),setTimeout(function(){i||(e.$ele.remove(),e.settings.onClosed&&e.settings.onClosed(e.$ele))},600)},reposition:function(e){var s=this,i='[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])',n=this.$ele.nextAll(i);1==this.settings.newest_on_top&&(n=this.$ele.prevAll(i)),n.each(function(){t(this).css(s.settings.placement.from,e),e=parseInt(e)+parseInt(s.settings.spacing)+t(this).outerHeight()})}}),t.notify=function(t,s){var i=new e(this,t,s);return i.notify},t.notifyDefaults=function(e){return s=t.extend(!0,{},s,e)},t.notifyClose=function(e){"undefined"==typeof e||"all"==e?t("[data-notify]").find('[data-notify="dismiss"]').trigger("click"):t('[data-notify-position="'+e+'"]').find('[data-notify="dismiss"]').trigger("click")}}); \ No newline at end of file diff --git a/static/image/coin16.png b/static/image/coin16.png new file mode 100644 index 0000000..e2fe18a Binary files /dev/null and b/static/image/coin16.png differ diff --git a/static/image/coin32.png b/static/image/coin32.png new file mode 100644 index 0000000..3043c96 Binary files /dev/null and b/static/image/coin32.png differ diff --git a/static/upload/church.jpg b/static/upload/church.jpg new file mode 100644 index 0000000..510f991 Binary files /dev/null and b/static/upload/church.jpg differ diff --git a/templates/base.html b/templates/base.html index e852041..bf3ac1d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -2,141 +2,141 @@ {% load staticfiles %} - - - - - - - - - - - - - {% block header %} - {% if title %}{{title}} - {% endif %}物志 - {% endblock %} - - - - - - {% block banner %} - - {% endblock %} - -
-
-
-
- {% block content %} -
-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-
- -
-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-
- -
-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-

这里是正文栏

-
+ + + + + + + + + + + + + + + {% block header %} + {% if title %}{{title}} - {% endif %}物志 + {% endblock %} + + + + + + {% block banner %} + + {% endblock %} + +
+
+
+
+ {% block content %} + + +
+

这里是正文栏

+

这里是正文栏

+

这里是正文栏

+

这里是正文栏

+

这里是正文栏

+
+ {% endblock%} + +
+ + - - -
-
- - -
-
-
- - 关于 - -
- -
- - - - Copyright ©2018 -
-
-
- - - - +
+

主题分区

+ +

全部

+ + {% for i in secs %} +

{{i.name}}

+ + {% endfor %} +
+
+

广告位

+
+ + {% endblock %} +
+
+
+ +
+
+
+ + 关于 + +
+ +
+ + + + Copyright ©2018 +
+
+
+ +
+ + diff --git a/templates/index.html b/templates/index.html index df169cf..0a93a07 100644 --- a/templates/index.html +++ b/templates/index.html @@ -11,27 +11,27 @@

{% if title %}{{title}}{% endif %}

{% block content %} - {% for i in arts %} -
-
-
-

-
-
-

{{i.title}}

-

{{i.detail|striptags|truncatechars:140|safe}}

-

-  {{i.publish_time}} -     -  {{i.author}} - - 阅读全文 - -
-
+ {% for i in arts %} +
+
+
+

+
+
+

{{i.title}}

+

{{i.detail|striptags|truncatechars:140|safe}}

+

+  {{i.publish_time}} +     +  {{i.author}} + + 阅读全文 + +
+
-
- {% endfor %} +
+ {% endfor %} {% endblock %} diff --git a/userpage/__pycache__/models.cpython-36.pyc b/userpage/__pycache__/models.cpython-36.pyc index b52bd16..02de966 100644 Binary files a/userpage/__pycache__/models.cpython-36.pyc and b/userpage/__pycache__/models.cpython-36.pyc differ diff --git a/userpage/migrations/0004_auto_20180228_1552.py b/userpage/migrations/0004_auto_20180228_1552.py new file mode 100644 index 0000000..5e8f7bd --- /dev/null +++ b/userpage/migrations/0004_auto_20180228_1552.py @@ -0,0 +1,25 @@ +# Generated by Django 2.0.2 on 2018-02-28 07:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('userpage', '0003_auto_20180226_1938'), + ] + + operations = [ + migrations.AddField( + model_name='profile', + name='point', + field=models.IntegerField(default=0), + preserve_default=False, + ), + migrations.AddField( + model_name='profile', + name='unread', + field=models.IntegerField(default=0), + preserve_default=False, + ), + ] diff --git a/userpage/migrations/__pycache__/0004_auto_20180228_1552.cpython-36.pyc b/userpage/migrations/__pycache__/0004_auto_20180228_1552.cpython-36.pyc new file mode 100644 index 0000000..138af37 Binary files /dev/null and b/userpage/migrations/__pycache__/0004_auto_20180228_1552.cpython-36.pyc differ diff --git a/userpage/models.py b/userpage/models.py index 3986b24..b28ddfb 100644 --- a/userpage/models.py +++ b/userpage/models.py @@ -1,6 +1,6 @@ from django.db import models from django.contrib.auth.models import User -from django.forms import ModelForm,Textarea +from django.forms import ModelForm,Textarea,TextInput,ClearableFileInput from django.db.models.signals import post_save from django.dispatch import receiver @@ -12,6 +12,8 @@ class Profile(models.Model): location = models.CharField(max_length=30, blank=True) #birth_date = models.DateField(null=True, blank=True) avatar = models.ImageField(upload_to='static/avatar/', blank=True, null=True) + point = models.IntegerField() + unread = models.IntegerField() def __str__(self): return self.user.username @@ -29,9 +31,19 @@ class UserForm(ModelForm): class Meta: model = User fields = ('first_name', 'last_name', 'email') + widgets = { + 'email':TextInput(attrs={'class':'form-control','placeholder':"E-mail"}), + 'first_name':TextInput(attrs={'class':'form-control','placeholder':"First Name"}), + 'last_name':TextInput(attrs={'class':'form-control','placeholder':"Last Name"}), + } class ProfileForm(ModelForm): class Meta: model = Profile - fields = ('location', 'avatar') - + fields = ('avatar',) + error_messages = { + 'avatar':{'required': '请上传头像'}, + } + widgets = { + 'avatar':ClearableFileInput(attrs={'style':'width:50%','class':'form-control','placeholder':"头像"}), + } diff --git a/userpage/templates/userpage/profile.html b/userpage/templates/userpage/profile.html index 0c91369..301c43c 100644 --- a/userpage/templates/userpage/profile.html +++ b/userpage/templates/userpage/profile.html @@ -1,21 +1,41 @@ {% extends "base.html"%} +{% block header %} +[ {{request.user}} ]用户详情 - 物志 +{% endblock %} + {% block content%} - {% if messages %} -
    - {% for message in messages %} - {{ message }} + + {% if user_form.errors %} + {% for field in user_form %} + {% for error in field.errors %} + + {% endfor %} {% endfor %} -
- {% endif %} - + {% endif %} + +
- + {% csrf_token %} {{ user_form.as_p }} {{ profile_form.as_p }} - +
{% endblock %}