def post(self, request): company = CompanyContainer(request.user) rq = RequestUtil() i = rq.get_event_info(request) context = { 'company': company.get_company(), 'countries': HomeUtil.get_countries(), 'states': HomeUtil.get_states(), 'tab': 'events', } if i: try: with transaction.atomic(): if company.new_event(i): return redirect('event:company_events') else: raise IntegrityError except IntegrityError: context['event'] = i context['errors'] = company.get_form().errors else: context['event'] = rq.get_info() context['errors'] = rq.get_errors() return render(request, self.template_name, context)
def company_index(request): if request.method == 'GET': company = CompanyContainer(request.user) if company.get_company() is None: return redirect('company:new') return render(request, 'manual/company/index.html', {'company': company.get_company(), 'tab': 'manual'}) raise Http404
def get(self, request, pk): company = CompanyContainer(request.user) context = { 'event': company.get_event(pk), 'company': company.get_company(), 'tab': 'events', } return render(request, self.template_name, context)
def get(self, request): company = CompanyContainer(request.user) context = { 'company': company.get_company(), 'countries': HomeUtil.get_countries(), 'states': HomeUtil.get_states(), 'tab': 'events', } return render(request, self.template_name, context)
def detail_view(request, pk): if request.method == 'GET': company = CompanyContainer(request.user) context = { 'event': company.get_event(pk), 'company': company.get_company(), 'tab': 'events', } return render(request, 'event/detail.html', context) raise Http404
def privacy_policy(request): if request.method == 'GET': user = UserUtil(request.user) context = {} if user.is_logged_in(): if user.get_user_type() == 'company': company = CompanyContainer(user.get_user()) context['logged'] = 'company' context['user_name'] = company.get_company().name elif user.get_user_type() == 'student': student = StudentContainer(user.get_user()) context['logged'] = 'student' context['user_name'] = student.get_student().name return render(request, 'home/privacy_policy.html', context) raise Http404
def company_index(request): if request.method == 'GET': event_page = request.GET.get('ep', 1) ex_event_page = request.GET.get('xep', 1) company = CompanyContainer(request.user) if company.get_company() is None: return redirect('company:new') msgs = MessageCenter.get_messages('company', company.get_company()) events = Pagination(company.get_events(), 10) ex_events = Pagination(company.get_expired_events(), 10) context = { 'company': company.get_company(), 'events': events.get_page(event_page), 'expired_events': ex_events.get_page(ex_event_page), 'messages': msgs, 'tab': 'events', } MessageCenter.clear_msgs(msgs) return render(request, 'event/company_index.html', context) raise Http404
def close_notifications(request, u): if request.method == 'GET': user = None if u == 'company': user = CompanyContainer(request.user).get_company() elif u == 'student': user = StudentContainer(request.user).get_student() if user: try: with transaction.atomic(): if MessageCenter.close_all_notifications(u, user): return HttpResponse('Notifications closed.', status=200) else: raise IntegrityError except IntegrityError: return HttpResponse('No notifications found.', status=400) return HttpResponse('Invalid user request.', status=400) raise Http404
def close_event(request, pk): if request.method == 'GET': company = CompanyContainer(request.user) context = { 'event': company.get_event(pk), 'company': company.get_company(), 'tab': 'events', } try: with transaction.atomic(): if company.close_event(pk): return HttpResponse('success', status=200) else: raise IntegrityError except IntegrityError: return HttpResponse(str(company.get_errors()), status=400) return render(request, 'event/detail.html', context) raise Http404
def post(self, request, ut): user = UserUtil(self.request.user) rq = RequestUtil() i = rq.get_user_change_info(self.request) if ut == 'company': self.template_name = 'home/company_change_form.html' elif ut == 'student': self.template_name = 'home/student_change_form.html' if i: if user.get_user().check_password(i['old_password']): try: with transaction.atomic(): if i['email']: if ut == 'student': student = StudentContainer(user.get_user()) if user.change_user_email(i, student=student.get_student()): return redirect('home:verify') else: raise IntegrityError elif ut == 'company': company = CompanyContainer(user.get_user()) if user.change_user_email(i, company=company.get_company()): if user.log_user_out(request): return redirect('home:verify') raise IntegrityError else: raise IntegrityError else: return render(request, self.template_name, {'error': 'Invalid request.'}) elif i['password']: if user.change_user_password(i): if user.log_user_out(self.request): if user.log_user_in( self.request, { 'email': user.get_user().email, 'password': i['password'] } ): m = 'Password changed successfully.' if ut == 'student': student = StudentContainer(user.get_user()) MessageCenter.new_notification('student', student.get_student(), 100, m) MessageCenter.new_message('student', student.get_student(), 'success', m) return redirect('student:index') elif ut == 'company': company = CompanyContainer(user.get_user()) MessageCenter.new_notification('company', company.get_company(), 100, m) MessageCenter.new_message('company', company.get_company(), 'success', m) return redirect('company:index') else: return redirect('home:index') raise IntegrityError except IntegrityError: return render(request, self.template_name, {'error': str(user.get_errors())}) else: return render(request, self.template_name, {'error': 'Incorrect password.'}) else: return render(request, self.template_name, {'error': str(rq.get_errors())})
def company_profile(request): if request.method == 'GET': company = CompanyContainer(request.user) return render(request, 'manual/company/profile.html', {'company': company.get_company(), 'tab': 'manual'}) raise Http404