def create(request): context = { 'authority_taples': MasterQuery().get_authority_taples(), 'user_status_taples': MasterQuery().get_user_status_taples() } html = render_to_string('student/userm/create.html', context=context, request=request) return HttpResponse(html)
def __new__(cls, *args, **kwargs): cls.__new_lock.acquire() if cls.__singleton is None: cls.__singleton = super(ApplicationUserQuery, cls).__new__(cls) cls.__master_query = MasterQuery() cls.__new_lock.release() return cls.__singleton
def test_get_user_status_dictionary(self): result = MasterQuery().get_user_status_dictionary() self.assertEqual(result, { '01': 'value3', '02': 'value4', '03': 'active' })
def __new__(cls, *args, **kwargs): cls.__new_lock.acquire() if cls.__singleton is None: cls.__singleton = super(AccessInformationService, cls).__new__(cls) cls.__access_information_query = AccessInformationQuery() cls.__access_information_repository = AccessInformationRepository() cls.__master_query = MasterQuery() cls.__new_lock.release() return cls.__singleton
def __new__(cls, *args, **kwargs): cls.__new_lock.acquire() if cls.__singleton is None: cls.__singleton = super(ApplicationUserService, cls).__new__(cls) cls.__master_query = MasterQuery() cls.__application_user_query = ApplicationUserQuery() cls.__application_user_repository = ApplicationUserRepository() cls.__numberingmasterquery = NumberingMasterQuery() cls.__new_lock.release() return cls.__singleton
def __search( request, email, full_name, target_sort_item, target_descending_order): offset = 0 result_list_count = ApplicationUserQuery().custom_count(email, full_name) result_list = ApplicationUserQuery().custom_query( email, full_name, offset, __limit, target_sort_item, target_descending_order) authority_dictionary = MasterQuery().get_authority_dictionary() user_status_dictionary = MasterQuery().get_user_status_dictionary() request.session['email'] = email request.session['full_name'] = full_name request.session['current_sort_item'] = target_sort_item request.session['current_descending_order'] = target_descending_order context = { 'result_list': result_list, 'result_list_count': result_list_count, 'authority_dictionary': authority_dictionary, 'user_status_dictionary': user_status_dictionary, 'current_sort_item': target_sort_item, 'current_descending_order': target_descending_order, 'current_page': offset + 1, 'limit': __limit } html = render_to_string( 'student/userm/search_result.html', context, request=request) return HttpResponse(html)
def update(request): form = UserIdForm(data=request.POST) if form.is_valid(): user_id = form.cleaned_data['user_id'] user = ApplicationUserQuery().get_user(user_id) context = { 'user': user, 'authority_taples': MasterQuery().get_authority_taples(), 'user_status_taples': MasterQuery().get_user_status_taples() } html = render_to_string('student/userm/update.html', context=context, request=request) return HttpResponse(html) else: return None
def __new__(cls, *args, **kwargs): cls.__new_lock.acquire() if cls.__singleton is None: cls.__singleton = super(LoginService, cls).__new__(cls) cls.__master_query = MasterQuery() cls.__application_user_query = ApplicationUserQuery() cls.__application_user_repository = ApplicationUserRepository() cls.__temporarily_login_url_query = TemporarilyLoginUrlQuery() cls.__temporarily_login_url_repository = TemporarilyLoginUrlRepository( ) cls.__new_lock.release() return cls.__singleton
def __paging(request, current_page, previous, next, target_page): offset, target_page = function.get_offset( previous, next, target_page, current_page, __limit) email = request.session['email'] full_name = request.session['full_name'] current_sort_item = request.session['current_sort_item'] current_descending_order = request.session['current_descending_order'] result_list_count = ApplicationUserQuery().custom_count(email, full_name) result_list = ApplicationUserQuery().custom_query( email, full_name, offset, __limit, current_sort_item, current_descending_order) authority_dictionary = MasterQuery().get_authority_dictionary() user_status_dictionary = MasterQuery().get_user_status_dictionary() context = { 'result_list': result_list, 'result_list_count': result_list_count, 'authority_dictionary': authority_dictionary, 'user_status_dictionary': user_status_dictionary, 'current_page': target_page, 'limit': __limit, 'current_sort_item': current_sort_item, 'current_descending_order': current_descending_order, 'authority_name': request.session['authority'] } html = render_to_string( 'student/userm/search_result.html', context, request=request) return HttpResponse(html)
def login(request): login_service = LoginService() onetime_password = request.GET.get("onetimepassword") active_user = login_service.get_active_user(onetime_password) if (active_user is not None): login_service.update_login_information(active_user) request.session['authority'] = MasterQuery().get_authority_value( active_user.authority) request.session['user_id'] = active_user.user_id return redirect('home') return render(request, 'student/temporary_url_expired.html')
def test_get_authority_taples(self): result = MasterQuery().get_authority_taples() self.assertEqual(result, [('01', 'value1'), ('02', 'value2')])
def test_get_event_type_request_login(self): result = MasterQuery().get_event_type_request_login() self.assertEqual(result, 'event_type')
def test_get_root_login_url(self): result = MasterQuery().get_root_login_url() self.assertEqual(result, 'url')
def test_get_active_user_status_sub_code(self): result = MasterQuery().get_active_user_status_sub_code() self.assertEqual(result, '03')
def test_get_temporary_time(self): result = MasterQuery().get_temporary_time() self.assertEqual(result, 15)
def test_get_user_status_taples(self): result = MasterQuery().get_user_status_taples() self.assertEqual(result, [('01', 'value3'), ('02', 'value4'), ('03', 'active')])
def test_get_value_case1(self): result = MasterQuery().get_value('00101') self.assertEqual(result, 'value1')
def test_get_value_case2(self): result = MasterQuery().get_value('001011') self.assertEqual(result, None)
def test_get_authority_dictionary(self): result = MasterQuery().get_authority_dictionary() self.assertEqual(result, {'01': 'value1', '02': 'value2'})
def test_get_authority_value(self): result = MasterQuery().get_authority_value('01') self.assertEqual(result, 'value1')