Login

Mini issue tracker

Author:
pbx
Posted:
February 26, 2007
Language:
Python
Version:
Pre .96
Score:
15 (after 19 ratings)

Described more fully on my blog, but the gist is: this model becomes a sort of mini-app in your admin, allowing you to record and track issues related to your other applications.

Sorting still needs some work.

UPDATED 2007-03-14: Fixed repeat in Admin.list_display (thanks, burly!); added Admin.list_filter; changed app list (why did I call that PROJECTS, anyway?) to omit "django.*" apps

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from django.db import models
from django.contrib.auth.models import User
from django.conf import settings

STATUS_CODES = (
    (1, 'Open'),
    (2, 'Working'),
    (3, 'Closed'),
    )

PRIORITY_CODES = (
    (1, 'Now'),
    (2, 'Soon'),
    (3, 'Someday'),
    )

apps = [app for app in settings.INSTALLED_APPS if not app.startswith('django.')]

class Ticket(models.Model):
    """Trouble tickets"""
    title = models.CharField(maxlength=100)
    project = models.CharField(blank=True, maxlength=100, choices= list(enumerate(apps)))
    submitted_date = models.DateField(auto_now_add=True)
    modified_date = models.DateField(auto_now=True)
    submitter = models.ForeignKey(User, related_name="submitter")
    assigned_to = models.ForeignKey(User)
    description = models.TextField(blank=True)
    status = models.IntegerField(default=1, choices=STATUS_CODES)
    priority = models.IntegerField(default=1, choices=PRIORITY_CODES)

    class Admin:
        list_display = ('title', 'status', 'priority', 'submitter', 
            'submitted_date', 'modified_date')
        list_filter = ('priority', 'status', 'submitted_date')
        search_fields = ('title', 'description',)

    class Meta:
        ordering = ('status', 'priority', 'submitted_date', 'title')

    def __str__(self):
        return self.title

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 10 months, 1 week ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 2 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
  5. Help text hyperlinks by sa2812 1 year, 6 months ago

Comments

buriy (on March 11, 2007):

bug: two submitted_date in list_display.

#

pbx (on March 14, 2007):

Thanks -- fixed!

I added a couple refinements that I've been using too.

#

SmileyChris (on April 11, 2007):

Instead of from YOURPROJECT import settings you should use from django.conf import settings

#

pbx (on April 13, 2007):

Good catch, fixed.

#

mrben (on November 24, 2008):

Could probably do with updating this to the v1.0 admin stuff. If I get a moment, I'll post up some code.

#

eter (on October 23, 2010):

Since Pre .96 version there is a bit of minor changes:

1) max_length instead of maxlength

2) you had better use unicode method instead of str.

#

Please login first before commenting.