Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

added categories to question form #64

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
be9c721
added categories to question form
Jul 25, 2014
4357a6c
Trying to add the plus button to the form...
wws9vh Jul 29, 2014
22b216d
Missed a change, forgot to import custom wrapper
wws9vh Jul 29, 2014
30aac90
Quick fix
wws9vh Jul 29, 2014
2b3b635
Fixed use of admin_media_prefix
wws9vh Jul 30, 2014
43dee90
Changed the static_url import
wws9vh Jul 30, 2014
bc5bccf
Just trying to make it work...
wws9vh Jul 30, 2014
b0dcad7
Fixed an import
wws9vh Jul 30, 2014
4cbbb6e
Import reverse
wws9vh Jul 30, 2014
47a9f39
hack
wws9vh Jul 30, 2014
e6165c9
hack
wws9vh Jul 30, 2014
4482550
hack
wws9vh Jul 30, 2014
3642e3b
hack
wws9vh Jul 30, 2014
2ec97ca
global name _ is not defined
wws9vh Jul 30, 2014
3f46605
import
wws9vh Jul 30, 2014
26be622
Think I know what the createview is for now
wws9vh Jul 30, 2014
56a5bde
Import
wws9vh Jul 30, 2014
379e56d
Trying to make the reverse work
wws9vh Jul 30, 2014
637e1f5
Added import for views
wws9vh Jul 30, 2014
1a75734
Trying the import this way now...
wws9vh Jul 30, 2014
f1e1807
Finally used pycharm to fix some more imports
wws9vh Jul 30, 2014
e556af8
Defining self.object because our createview throws an error about not…
wws9vh Jul 30, 2014
63e43f5
Defined the model:
wws9vh Jul 30, 2014
ff59300
Added an import back
wws9vh Jul 30, 2014
3db517d
Updated template
wws9vh Jul 30, 2014
8f42eba
Let's try this again
wws9vh Jul 30, 2014
1c45209
One more time
wws9vh Jul 30, 2014
8ea97c2
Caught an omission of the queryset, trying some things to fix stuff
wws9vh Jul 30, 2014
6db95e9
fixing a deprecated url tag
wws9vh Jul 30, 2014
2aded2e
Added some stuff back
wws9vh Jul 30, 2014
f12034f
Broke results by category, seeing if the javascript is overwritten
wws9vh Jul 30, 2014
88c1a18
Trying a different add_url
wws9vh Jul 31, 2014
4331e34
Updated add_link.gif reference
wws9vh Jul 31, 2014
221a76d
Updated css to get the plus icon to appear
wws9vh Jul 31, 2014
a2f5965
Let's try that again
wws9vh Jul 31, 2014
3193711
Trying to make the javascript work by adding it directly to the template
wws9vh Jul 31, 2014
1e90462
Needed an import
wws9vh Jul 31, 2014
7f2ec5f
Trying this - putting the js tag in the base template
wws9vh Jul 31, 2014
42541cb
Giving up on the popup, trying to fix other bugs now by first cleanin…
wws9vh Jul 31, 2014
140f324
Still cleaning up
wws9vh Jul 31, 2014
8f8a35a
Trying out removing unused js
wws9vh Jul 31, 2014
3db8199
This should conclude the cleanup
wws9vh Jul 31, 2014
c39b0c5
Trying out a redirect after adding a new category
wws9vh Jul 31, 2014
c214c78
Caught a bug displaying results for a category
wws9vh Jul 31, 2014
879ee74
Modifying the redirect url
wws9vh Jul 31, 2014
695175f
Removing the redirect attempt
wws9vh Jul 31, 2014
b4c2852
Fixed the css to make the search bar work
wws9vh Jul 31, 2014
7ee841f
Changed question description to richtextfield
wws9vh Aug 4, 2014
ad42e35
Trying a styling hack to fix new richtextfield in form
wws9vh Aug 4, 2014
a5694fc
Set user as a required field to fix bug with questions ruining our da…
wws9vh Aug 4, 2014
74862d0
Generated migration from develop branch
wws9vh Aug 4, 2014
418b465
Made response a richtextfield
wws9vh Aug 6, 2014
c0a34c1
Generated migration for richtextfield
wws9vh Aug 6, 2014
a155328
Working on updating the templates to work with rtf, and removed markdown
wws9vh Aug 6, 2014
8e3bce4
Removed the load for markup, added filter tags for rtf
wws9vh Aug 6, 2014
1eb7b6d
Removed markdown reference from help text
wws9vh Aug 8, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions knowledge/forms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from django import forms
from django.utils.translation import ugettext_lazy as _

from knowledge import settings
from knowledge.models import Question, Response
import settings
from models import Question, Response, Category
from widgets import CustomRelatedFieldWidgetWrapper
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.core.urlresolvers import reverse

OPTIONAL_FIELDS = ['alert', 'phone_number']
OPTIONAL_FIELDS = ['alert', 'phone_number', 'categories']


__todo__ = """
Expand All @@ -26,7 +29,7 @@ def QuestionForm(user, *args, **kwargs):
else:
selected_fields = ['name', 'email', 'title', 'body']
else:
selected_fields = ['user', 'title', 'body', 'status']
selected_fields = ['user', 'title', 'body', 'status', 'categories']

if settings.ALERTS:
selected_fields += ['alert']
Expand Down Expand Up @@ -54,6 +57,14 @@ def __init__(self, *args, **kwargs):
if qf:
qf.widget = qf.hidden_widget()
qf.required = False

#Not sure about 'category' or 'category_create'
self.fields['categories'].widget = CustomRelatedFieldWidgetWrapper(
FilteredSelectMultiple(('category'),False,),
reverse('admin:knowledge_category_add'),
True)

self.fields['categories'].queryset = Category.objects.all()

# honey pot!
phone_number = forms.CharField(required=False)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):

# Changing field 'Question.body'
db.alter_column(u'knowledge_question', 'body', self.gf('mezzanine.core.fields.RichTextField')(null=True))

# Changing field 'Question.user'
db.alter_column(u'knowledge_question', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True))

# Changing field 'Response.user'
db.alter_column(u'knowledge_response', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True))

def backwards(self, orm):

# Changing field 'Question.body'
db.alter_column(u'knowledge_question', 'body', self.gf('django.db.models.fields.TextField')(null=True))

# Changing field 'Question.user'
db.alter_column(u'knowledge_question', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[user_model_label], null=True))

# Changing field 'Response.user'
db.alter_column(u'knowledge_response', 'user_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[user_model_label], null=True))

models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'knowledge.category': {
'Meta': {'ordering': "['title']", 'object_name': 'Category'},
'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lastchanged': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
u'knowledge.question': {
'Meta': {'ordering': "['-added']", 'object_name': 'Question'},
'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'body': ('mezzanine.core.fields.RichTextField', [], {'null': 'True', 'blank': 'True'}),
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['knowledge.Category']", 'symmetrical': 'False', 'blank': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lastchanged': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'private'", 'max_length': '32', 'db_index': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
},
u'knowledge.response': {
'Meta': {'ordering': "['added']", 'object_name': 'Response'},
'accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'body': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lastchanged': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'responses'", 'to': u"orm['knowledge.Question']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'inherit'", 'max_length': '32', 'db_index': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
}
}

complete_apps = ['knowledge']
96 changes: 96 additions & 0 deletions knowledge/migrations/0005_auto__chg_field_response_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):

# Changing field 'Response.body'
db.alter_column(u'knowledge_response', 'body', self.gf('mezzanine.core.fields.RichTextField')(null=True))

def backwards(self, orm):

# Changing field 'Response.body'
db.alter_column(u'knowledge_response', 'body', self.gf('django.db.models.fields.TextField')(null=True))

models = {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'knowledge.category': {
'Meta': {'ordering': "['title']", 'object_name': 'Category'},
'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lastchanged': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
u'knowledge.question': {
'Meta': {'ordering': "['-added']", 'object_name': 'Question'},
'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'body': ('mezzanine.core.fields.RichTextField', [], {'null': 'True', 'blank': 'True'}),
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['knowledge.Category']", 'symmetrical': 'False', 'blank': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lastchanged': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'locked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'private'", 'max_length': '32', 'db_index': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'})
},
u'knowledge.response': {
'Meta': {'ordering': "['added']", 'object_name': 'Response'},
'accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'alert': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'body': ('mezzanine.core.fields.RichTextField', [], {'null': 'True', 'blank': 'True'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lastchanged': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'}),
'question': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'responses'", 'to': u"orm['knowledge.Question']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'inherit'", 'max_length': '32', 'db_index': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True'})
}
}

complete_apps = ['knowledge']
12 changes: 7 additions & 5 deletions knowledge/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from knowledge.managers import QuestionManager, ResponseManager
from knowledge.signals import knowledge_post_save

from mezzanine.core.fields import RichTextField

STATUSES = (
('public', _('Public')),
('private', _('Private')),
Expand Down Expand Up @@ -45,7 +47,7 @@ class KnowledgeBase(models.Model):
added = models.DateTimeField(auto_now_add=True)
lastchanged = models.DateTimeField(auto_now=True)

user = models.ForeignKey('auth.User' if django.VERSION < (1, 5, 0) else django_settings.AUTH_USER_MODEL, blank=True,
user = models.ForeignKey('auth.User' if django.VERSION < (1, 5, 0) else django_settings.AUTH_USER_MODEL, blank=False,
null=True, db_index=True)
alert = models.BooleanField(default=settings.ALERTS,
verbose_name=_('Alert'),
Expand Down Expand Up @@ -150,9 +152,9 @@ class Question(KnowledgeBase):
title = models.CharField(max_length=255,
verbose_name=_('Question'),
help_text=_('Enter your question or suggestion.'))
body = models.TextField(blank=True, null=True,
body = RichTextField(blank=True, null=True,
verbose_name=_('Description'),
help_text=_('Please offer details. Markdown enabled.'))
help_text=_('Please offer details.'))

status = models.CharField(
verbose_name=_('Status'),
Expand Down Expand Up @@ -254,9 +256,9 @@ class Response(KnowledgeBase):
question = models.ForeignKey('knowledge.Question',
related_name='responses')

body = models.TextField(blank=True, null=True,
body = RichTextField(blank=True, null=True,
verbose_name=_('Response'),
help_text=_('Please enter your response. Markdown enabled.'))
help_text=_('Please enter your response.'))
status = models.CharField(
verbose_name=_('Status'),
max_length=32, choices=STATUSES_EXTENDED,
Expand Down
8 changes: 5 additions & 3 deletions knowledge/static/knowledge/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; }
.dk-inner input {
margin: 0; }
.dk-inner .dk-content .dk-widget form.dk-form .field-wrapper .field-input span.mceEditor table.mceLayout {
width: 100% !important; }
.dk-inner .quiet {
font-weight: normal;
color: #888; }
Expand Down Expand Up @@ -36,7 +38,7 @@
border: 1px solid #ccc;
font-size: 16px;
width: 87%;
height: 16px;
/*height: 16px;*/
float: left; }
.dk-inner .dk-search .submit-question-search {
height: 34px;
Expand Down Expand Up @@ -90,8 +92,8 @@
margin-bottom: 1em; }
.dk-inner .dk-content .dk-widget img {
max-width: 96%;
padding: 1%;
border: 1px solid #ccc; }
/*padding: 1%;
border: 1px solid #ccc;*/ }
.dk-inner .dk-content .dk-widget ol.question-list {
font-size: 14px;
margin-left: 10px; }
Expand Down
Loading