* Use markdown on knowledgebase pages

* KB item 'last updated' only gets set on a new item
* Allow linking to /tickets/submit/?queue=slug to pre-populate the 'Queue' folder
This commit is contained in:
Ross Poulton 2008-10-07 06:52:52 +00:00
parent 3f8fc2cd68
commit 5914e98d43
6 changed files with 20 additions and 8 deletions

View File

@ -20,6 +20,10 @@ class AttachmentInline(admin.StackedInline):
class FollowUpAdmin(admin.ModelAdmin): class FollowUpAdmin(admin.ModelAdmin):
inlines = [TicketChangeInline, AttachmentInline] inlines = [TicketChangeInline, AttachmentInline]
class KBItemAdmin(admin.ModelAdmin):
list_display = ('category', 'title', 'last_updated',)
list_display_links = ('title')
admin.site.register(Ticket, TicketAdmin) admin.site.register(Ticket, TicketAdmin)
admin.site.register(Queue, QueueAdmin) admin.site.register(Queue, QueueAdmin)
admin.site.register(FollowUp, FollowUpAdmin) admin.site.register(FollowUp, FollowUpAdmin)
@ -27,4 +31,4 @@ admin.site.register(PreSetReply)
admin.site.register(EscalationExclusion) admin.site.register(EscalationExclusion)
admin.site.register(EmailTemplate) admin.site.register(EmailTemplate)
admin.site.register(KBCategory) admin.site.register(KBCategory)
admin.site.register(KBItem) admin.site.register(KBItem, KBItemAdmin)

File diff suppressed because one or more lines are too long

View File

@ -794,10 +794,12 @@ class KBItem(models.Model):
_('Last Updated'), _('Last Updated'),
help_text=_('The date on which this question was most recently ' help_text=_('The date on which this question was most recently '
'changed.'), 'changed.'),
blank=True,
) )
def save(self, force_insert=False, force_update=False): def save(self, force_insert=False, force_update=False):
self.last_updated = datetime.now() if not self.last_updated:
self.last_updated = datetime.now()
return super(KBItem, self).save(force_insert, force_update) return super(KBItem, self).save(force_insert, force_update)
def _score(self): def _score(self):
@ -924,4 +926,3 @@ def create_usersettings(sender, created_models=[], instance=None, created=False,
models.signals.post_syncdb.connect(create_usersettings) models.signals.post_syncdb.connect(create_usersettings)
models.signals.post_save.connect(create_usersettings, sender=User) models.signals.post_save.connect(create_usersettings, sender=User)

View File

@ -12,7 +12,7 @@
<tr class='row_columnheads'><th colspan='3'>{% trans "Article" %}</th></tr> <tr class='row_columnheads'><th colspan='3'>{% trans "Article" %}</th></tr>
{% for item in items %} {% for item in items %}
<tr class='row_even row_hover'><th><a href='{{ item.get_absolute_url }}'>{{ item.title }}</a></th><td>{{ item.score }}</td><td>{{ item.last_updated|timesince }}</td></tr> <tr class='row_even row_hover'><th><a href='{{ item.get_absolute_url }}'>{{ item.title }}</a></th><td>Rating: {{ item.score }}</td><td>Last Update: {{ item.last_updated|timesince }} ago</td></tr>
<tr class='row_odd'><td colspan='3'>{{ item.question }}</td></tr> <tr class='row_odd'><td colspan='3'>{{ item.question }}</td></tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -1,4 +1,4 @@
{% extends "helpdesk/public_base.html" %}{% load i18n %} {% extends "helpdesk/public_base.html" %}{% load i18n %}{% load markup %}
{% block helpdesk_body %} {% block helpdesk_body %}
<h2>{% blocktrans with item.title as item %}Knowledgebase: {{ item }}{% endblocktrans %}</h2> <h2>{% blocktrans with item.title as item %}Knowledgebase: {{ item }}{% endblocktrans %}</h2>
@ -7,7 +7,7 @@
<tr class='row_tablehead'><td>{{ item.title }}</td></tr> <tr class='row_tablehead'><td>{{ item.title }}</td></tr>
<tr class='row_even row_hover'><th>{{ item.question }}</th></tr> <tr class='row_even row_hover'><th>{{ item.question }}</th></tr>
<tr class='row_odd'><td>{{ item.answer }}</td></tr> <tr class='row_odd'><td>{{ item.answer|markdown }}</td></tr>
</table> </table>
<p>{% blocktrans with item.category.title as category_title and item.category.get_absolute_url as category_url %}View <a href='{{ category_url }}'>other <em>{{ category_title }}</em> articles</a>, or continue <a href='../'>viewing other knowledgebase articles</a>.{% endblocktrans %}</p> <p>{% blocktrans with item.category.title as category_title and item.category.get_absolute_url as category_url %}View <a href='{{ category_url }}'>other <em>{{ category_title }}</em> articles</a>, or continue <a href='../'>viewing other knowledgebase articles</a>.{% endblocktrans %}</p>

View File

@ -38,7 +38,14 @@ def homepage(request):
ticket.submitter_email) ticket.submitter_email)
) )
else: else:
form = PublicTicketForm() try:
queue = Queue.objects.get(slug=request.GET.get('queue', None))
except Queue.DoesNotExist:
queue = None
initial_data = {}
if queue:
initial_data['queue'] = queue.id
form = PublicTicketForm(initial=initial_data)
form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)] form.fields['queue'].choices = [('', '--------')] + [[q.id, q.title] for q in Queue.objects.filter(allow_public_submission=True)]
return render_to_response('helpdesk/public_homepage.html', return render_to_response('helpdesk/public_homepage.html',