I found A good document, that explains a lot.
http://enodev.ath.cx/save/www.djangoproject.com/documentation/model_api/
but it still can not import name meta.  I don't know where this is
coming from.


from django.db.models import meta
from django.contrib.auth.models import User
#from django.contrib.auth.models import users
from django.oldforms import FormField, validators
from datetime import date
import datetime


def isValidTime(field_data, all_data):
  if all_data.has_key('worked') and all_data['worked'] == "on":
    try:
      if not (0<=int(field_data)<=100):
        raise validators.ValidationError("Percent Federal Time must be
between 0 and 100")
    except ValueError:
      raise validators.ValidationError("Percent Federal Time must be
between 0 and 100")

class Entry(meta.Model):
        date = meta.DateField('entry date', default=date.today())
        user = meta.ForeignKey(User, unique_for_date="date")
        time = meta.SmallIntegerField('federal percent', default=0,
validator_list=[isValidTime])
        worked = meta.BooleanField('did work', default=True)

        def __repr__(self):
                return "(%s) %s" % (self.date.__str__(),
self.get_user().get_full_name())

        def get_absolute_url(self):
                return "/app/timesheets/%s/%i/%i/%i/" % 
(self.get_user().username,
self.date.year, self.date.month, self.date.day)

        class META:
                admin = meta.Admin()

        def isok(self, cutoff_date = datetime.date.today()):
          return (self.id!='') or (self.date>cutoff_date)

        def get_date(self):
          return self.date.strftime("%x")

        def get_weekday(self):
          return self.date.strftime("%a")

        def istoday(self):
          return self.date == datetime.date.today()

        def status_text(self):
          if not self.worked: s = "--"
          elif self.date <= datetime.date.today():
            if not self.isok(): s = "Missing"
            else: s =  "%i%%" % self.time
          elif self.id != '': s = "%i%%" % self.time
          else: s = ''

          return s



class JobPosition(meta.Model):
    position = meta.CharField('Job Title', maxlength=30)
    address1 = meta.CharField('Address Line 1', maxlength=40)
    address2 = meta.CharField('Address Line 1', maxlength=40,
blank=True)
    city = meta.CharField('City', maxlength=20)
    state = meta.CharField('State', maxlength=2)
    zip = meta.CharField('Zip', maxlength=5)
    user = meta.OneToOneField(User)

    class META:
                admin = meta.Admin()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to