Sfoglia il codice sorgente

Signed-off-by: zry <admin@z-touhou.org>

zry 8 anni fa
parent
commit
aa9cccc828
2 ha cambiato i file con 19 aggiunte e 1 eliminazioni
  1. 1 0
      forms.py
  2. 18 1
      templates/home/post.grant.html

+ 1 - 0
forms.py

@@ -71,6 +71,7 @@ class PostPermForm(forms.ModelForm):
 		self.fields['private'].label=u'设为私密文章'
 		self.fields['passwdlck'].label=u'使用密码保护'
 		self.fields['passwd'].label=u'访问密码'
+		self.fields['passwd'].required=False
 		self.fields['readgrp'].label=u'允许访问的用户组'
 		self.fields['readgrp'].required=False
 		self.fields['readuin'].label=u'额外允许访问的用户'

+ 18 - 1
templates/home/post.grant.html

@@ -24,7 +24,7 @@
 {% endblock %}
 
 {% block content %}
-<form class="form-horizontal" role="form" action="" method="POST" >
+<form class="form-horizontal" role="form" action="" method="POST" onkeydown="if(event.keyCode==13)return false;" >
 	{% csrf_token %}
     {% for item in form %}
     <input type="hidden" name="rfm" value="{{rfm}}">
@@ -55,6 +55,23 @@
     });
     $("input[type='checkbox']").bootstrapSwitch();
     //$("select[name='readuin']").tagsinput('items');
+    $("select[name='readuin']").tagsinput({
+    	confirmKeys: [13, 32, 44],
+    	tagClass: function(item) {
+			switch (item.continent) {
+				case 'right'   : return 'label label-primary';
+				case 'wrong'  : return 'label label-danger label-important';
+			}
+		},
+    });
+    $("select[name='readuin']").on('beforeItemAdd', function(event) {
+		// event.item: contains the item
+		// event.cancel: set to true to prevent the item getting added
+		console.log("id: "+item.id);
+		console.log("text: "+item.text);
+		console.log("container: "+item.continent);
+		item.id = "233";
+	});
     // $("select[name='readuin']").tagsinput({
     // 	confirmKeys: [13, 32, 44],
     // 	itemValue: function(item){