Beispiel #1
0
 def userCreate(pSession, pRecord):
     lRet = ''
     if 'UserGUID' in pSession and 'UserIsAdmin' in pSession and pSession['UserIsAdmin'] == True:
         lFields = Internal.fields(User)
         lValid = True
         if lValid and len(pRecord) > len(lFields):
             lValid = False
         for lField in lFields:
             if lField not in pRecord:
                 lValid = False
                 break   
         if lValid and pRecord['UserGUID'] != '':
             lValid = False
         if lValid:
             pRecord['UserGUID'] = str(uuid4()).upper()
             try:
                 if pRecord['isAdmin'] is None:
                     pRecord['isAdmin'] = False
                 if pRecord['ownClient'] is None:
                     pRecord['ownClient'] = False
                 if pRecord['commonClient'] is None:
                     pRecord['commonClient'] = False
                 lUser = User(**pRecord)
                 lUser.save()
                 lRet = pRecord['UserGUID']
             except:# Exception as lException: # for debug
                 pass
     return lRet
Beispiel #2
0
from EasyExtJS4 import Ext
from calendar import timegm
from datetime import datetime
from datetime import timedelta
from uuid import uuid4
from hashlib import sha1

from django.db.models import Q
from hourstracker.models import User, Client, Task, Time

try:
    if User.objects.count() == 0:
        lAdmin = User(UserGUID = str(uuid4()).upper(),
                      isAdmin = True,
                      eMail = 'admin',
                      Password = sha1('admin').hexdigest())
        lAdmin.save()
except:
    pass
     
class Internal(object):

    @staticmethod
    def fields(pModel):
        lRet = list()
        for lField in pModel._meta.fields:
            lRet.append(lField.name)
        return lRet

    @staticmethod
    def localTime(pDateTime):