Ignore:
Timestamp:
29 Jun 2012, 10:21:03 (12 years ago)
Author:
Henrik Bettermann
Message:

Generate md5 andate_id from timestamp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py

    r8846 r8847  
    2020"""
    2121import grok
     22import hashlib
    2223from datetime import datetime, timedelta
     24from time import time
    2325from grok import index
    2426from waeup.kofa.interfaces import IUserAccount
     
    3234    grok.provides(IMandate)
    3335
    34     def __init__(self, days=1):
     36    def __init__(self, days=1, category=None, mandate_id=None):
    3537        super(Mandate, self).__init__()
    3638        self.creation_date = datetime.utcnow() # offset-naive datetime
    3739        delta = timedelta(days=days)
    3840        self.expires = datetime.utcnow() + delta
    39         self.mandate_id = None
    40         self.category = None
     41        if mandate_id is None:
     42            timestamp = "%d" % int(time()*1000)
     43            mandate_id = hashlib.md5(timestamp).hexdigest()
     44        self.mandate_id = mandate_id
     45        self.category = category
    4146        self.params = {}
    4247        return
Note: See TracChangeset for help on using the changeset viewer.