- initial client handling code
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@213 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
bf7992a600
commit
c84fc9a90c
62 changed files with 194 additions and 3086 deletions
11
gnuviechadmin/__init__.py
Normal file
11
gnuviechadmin/__init__.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
# This file is part of gnuviechadmin.
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# Author: Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright (c) 2007, Jan Dittberner
|
||||
# Version: $Id$
|
||||
|
||||
"""
|
||||
This is the gnuviechadmin package.
|
||||
|
||||
"""
|
78
gnuviechadmin/client.py
Normal file
78
gnuviechadmin/client.py
Normal file
|
@ -0,0 +1,78 @@
|
|||
# This file is part of gnuviechadmin.
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# Author: Jan Dittberner <jan@dittberner.info>
|
||||
# Copyright (c) 2007 Jan Dittberner
|
||||
# Version: $Id$
|
||||
|
||||
from sqlalchemy import *
|
||||
|
||||
meta = BoundMetaData('sqlite:///database.txt')
|
||||
client_table = Table('clients', meta,
|
||||
Column('clientid', Integer, primary_key=True),
|
||||
Column('title', String(10)),
|
||||
Column('firstname', String(64), nullable=False),
|
||||
Column('lastname', String(64), nullable=False),
|
||||
Column('address1', String(64), nullable=False),
|
||||
Column('address2', String(64)),
|
||||
Column('zip', String(7), nullable=False),
|
||||
Column('city', String(64), nullable=False),
|
||||
Column('country', String(5), nullable=False),
|
||||
Column('phone', String(20), nullable=False),
|
||||
Column('mobile', String(20)),
|
||||
Column('fax', String(20)),
|
||||
Column('email', String(64), unique=True, nullable=False))
|
||||
client_table.create(checkfirst=True)
|
||||
|
||||
class Client(object):
|
||||
"""This class provides a client representation"""
|
||||
def __init__(self, clientdata):
|
||||
mandatory = ('firstname', 'lastname', 'address1', 'zip', 'city',
|
||||
'email', 'phone', 'country')
|
||||
data = {"country": "de", "title": None, "address2": None,
|
||||
"mobile": None, "fax": None, "organisation": None}
|
||||
for key in clientdata.keys():
|
||||
data[key] = clientdata[key]
|
||||
for key in mandatory:
|
||||
if not key in data:
|
||||
print "mandatory client field %s is missing" % (key)
|
||||
self = None
|
||||
return
|
||||
self.title = data["title"]
|
||||
self.firstname = data["firstname"]
|
||||
self.lastname = data["lastname"]
|
||||
self.address1 = data["address1"]
|
||||
self.address2 = data["address2"]
|
||||
self.organisation = data["organisation"]
|
||||
self.zip = data["zip"]
|
||||
self.city = data["city"]
|
||||
self.country = data["country"]
|
||||
self.phone = data["phone"]
|
||||
self.mobile = data["mobile"]
|
||||
self.fax = data["fax"]
|
||||
self.email = data["email"]
|
||||
|
||||
def __repr__(self):
|
||||
return """Client (Id %(clientid)d):
|
||||
Name: %(title)s %(firstname)s %(lastname)s
|
||||
Address: %(address1)s
|
||||
%(address2)s
|
||||
%(zip)s %(city)s (%(country)s)
|
||||
Phone: %(phone)s
|
||||
Mobile: %(mobile)s
|
||||
Fax: %(fax)s
|
||||
Email: %(email)s""" % ({'clientid' : self.clientid,
|
||||
'title' : self.title,
|
||||
'firstname' : self.firstname,
|
||||
'lastname' : self.lastname,
|
||||
'address1' : self.address1,
|
||||
'address2' : self.address2,
|
||||
'zip' : self.zip,
|
||||
'city' : self.city,
|
||||
'country' : self.country,
|
||||
'phone' : self.phone,
|
||||
'mobile' : self.mobile,
|
||||
'fax' : self.fax,
|
||||
'email' : self.email})
|
||||
|
||||
clientmapper = mapper(Client, client_table)
|
Loading…
Add table
Add a link
Reference in a new issue