Source

pinyomi / pinyin / models.py

Full commit
# -*- coding: utf-8 -*-
#----------------------------------------------------------------------------#
# models.py
# Lars Yencken <lars.yencken@gmail.com>
# vim: ts=4 sw=4 sts=4 et tw=78:
# Fri Dec  8 11:46:17 2006
#
#----------------------------------------------------------------------------#

""" The database models for the pinyin lookup interface.
"""

#----------------------------------------------------------------------------#

from django.db import models
from www.settings import DEFAULT_ENCODING

#----------------------------------------------------------------------------#
# LOGGING TRANSACTIONS
#----------------------------------------------------------------------------#

class LookupLog(models.Model):
    """ A log kept of any lookup.
    """
    #------------------------------------------------------------------------#
    # PUBLIC
    #------------------------------------------------------------------------#

    # Query string
    query = models.CharField(max_length=50)

    # The target that they were looking for, and its rank in the results.
    target = models.CharField(max_length=30, null=True, blank=True)

    # The target language being looked up.
    LANG_CHOICES = (
            ('cn', 'Chinese'),
            ('jp', 'Japanese'),
        )
    targetLanguage = models.CharField(max_length=2, choices=LANG_CHOICES)

    # The ip address of the user access.
    ipAddress = models.IPAddressField()

    # The timestamp for the access.
    timestamp = models.DateTimeField(auto_now_add=True)

    # If we have a previous try recorded. 
    previousTry = models.ForeignKey('self', null=True, blank=True)

    # Whether this example was just for testing.
    testing = models.BooleanField(default=False)

    #------------------------------------------------------------------------#

    class Admin:
        list_display = ('query', 'target', 'targetLanguage', 'timestamp',
                'ipAddress', 'testing')
        list_filter = ('timestamp', 'targetLanguage', 'testing')
        ordering = ('-timestamp',)
        pass

    #------------------------------------------------------------------------#

    class Meta:
        pass

    #------------------------------------------------------------------------#

    def __str__(self):
        return '"%s" on %s' % (self.query, self.timestamp)

    #------------------------------------------------------------------------#
    # PRIVATE
    #------------------------------------------------------------------------#
    
    #------------------------------------------------------------------------#

#----------------------------------------------------------------------------#