コード例 #1
0
ファイル: account_test.py プロジェクト: featx/palmcom
 def test(self):
     with switch_db(_Account, 'test') as Account:
         account = Account(work_id="201401204", username="******", email="*****@*****.**",
                           cell_phone_number="13300130013")
         password = "******"
         account.password = md5(bytes(password, "utf8")).hexdigest().upper()
         account.save()
         a = AccountService.find_out_account("201401204", "123456")
         self.assertEqual(account.id, a.id)
         aa = AccountService.find_out_account("palmtale", "123456")
         self.assertEqual(account.id, aa.id)
         aaa = AccountService.find_out_account("*****@*****.**", "123456")
         self.assertEqual(account.id, aaa.id)
         aaaa = AccountService.find_out_account("13300130013", "123456")
         self.assertEqual(account.id, aaaa.id)
コード例 #2
0
class IndexView:
    def __init__(self, request):
        self.request = request
        from core.account import AccountService
        self.__account_service = AccountService()
        self.__log_user = None

    @view_config(route_name='index', renderer='templates/index.pt')
    def index(self):
        username = '******'
        from hashlib import md5
        password = md5(bytes('123456789', 'utf8')).hexdigest().upper()
        account = self.__account_service.find_out_account(username, password)
        if account is None:
            return {}
        self.request.session['login_user'] = account
        from datetime import datetime
        now = datetime.now()

        from core.sign import SignStorage
        signs = SignStorage().retrieve_from_to(
            account.email, now.replace(hour=5, minute=0, second=0),
            now.replace(hour=23, minute=59, second=59))
        sign_time = ''
        if len(signs) > 0:
            sign_time = signs[0].get('timestamp')
        if isinstance(sign_time, datetime):
            sign_time = sign_time.strftime('%H:%M:%S')
        return {
            'login_user': {
                'display_name': account.display_name,
                'sign_in_time': sign_time
            }
        }
コード例 #3
0
ファイル: index.py プロジェクト: palm-s/palmgate
class IndexView:
    def __init__(self, request):
        self.request = request
        from core.account import AccountService
        self.__account_service = AccountService()
        self.__log_user = None

    @view_config(route_name='index', renderer='templates/index.pt')
    def index(self):
        username = '******'
        from hashlib import md5
        password = md5(bytes('123456789', 'utf8')).hexdigest().upper()
        account = self.__account_service.find_out_account(username, password)
        if account is None:
            return {}
        self.request.session['login_user'] = account
        from datetime import datetime
        now = datetime.now()

        from core.sign import SignStorage
        signs = SignStorage().retrieve_from_to(account.email, now.replace(hour=5, minute=0, second=0),
                                               now.replace(hour=23, minute=59, second=59))
        sign_time = ''
        if len(signs) > 0:
            sign_time = signs[0].get('timestamp')
        if isinstance(sign_time, datetime):
            sign_time = sign_time.strftime('%H:%M:%S')
        return {'login_user':{'display_name':account.display_name,
                                  'sign_in_time':sign_time}}
コード例 #4
0
ファイル: account_test.py プロジェクト: featx/palmcom
 def tearDown(self):
     with switch_db(_Account, 'test') as Account:
         Account.drop_collection()
     a = AccountService.find_out_account("2014090801", '123456')
     if a is None:
         _Account(work_id="2014090801", username="******", email="*****@*****.**",
                  cell_phone_number="13303030033",
                  password=md5(bytes('123456', 'utf8')).hexdigest().upper()).save()
コード例 #5
0
 def index(self):
     if self.username is None:
         account = self.request.session.get(LOGGED_ACCOUNT_KEY, None)
     else:
         password = self.request.params.get('password', None)
         account = AccountService.find_out_account(self.username, password)
     if account is None:
         return HTTPTemporaryRedirect(location="/in.log")
     else:
         self.request.session[LOGGED_ACCOUNT_KEY] = account
         return {}
コード例 #6
0
ファイル: profile_test.py プロジェクト: featx/palmcom
 def test_work_time(self):
     account = _Account(work_id="201409221941",
                        username="******",
                        password=md5(bytes("123456",
                                           "utf8")).hexdigest().upper(),
                        email="*****@*****.**",
                        cell_phone_number="1233112321")
     account.save()
     a = AccountService.find_out_account('palmtale', '123456')
     self.assertIsNotNone(a,
                          "Test error caused by the account did not found")
     ProfileService.set_work_time(a, "09:00:00", "18:00:00")
     work_start, work_end = ProfileService.find_work_time(a)
     from datetime import datetime
     self.assertEqual(work_start,
                      datetime.strptime("090000", "%H%M%S").time())
     self.assertEqual(work_end,
                      datetime.strptime("180000", "%H%M%S").time())
コード例 #7
0
 def __init__(self, request):
     self.request = request
     from core.account import AccountService
     self.__account_service = AccountService()
     self.__log_user = None
コード例 #8
0
ファイル: index.py プロジェクト: palm-s/palmgate
 def __init__(self, request):
     self.request = request
     from core.account import AccountService
     self.__account_service = AccountService()
     self.__log_user = None