コード例 #1
0
ファイル: views.py プロジェクト: madmax330/Jobin
def edit_reference(request, pk):

    if request.method == 'POST':
        student = StudentContainer(request.user)
        rq = RequestUtil()
        i = rq.get_reference_info(request)
        if i:

            try:
                with transaction.atomic():
                    if student.edit_reference(pk, i):
                        m = 'Reference edited successfully.'
                        MessageCenter.new_message('student', student.get_student(), 'success', m)
                        return HttpResponse(m, status=200)
                    else:
                        raise IntegrityError
            except IntegrityError:
                m = str(student.get_errors())
                return HttpResponse(m, status=400)

        else:
            m = str(rq.get_errors())
            return HttpResponse(m, status=400)

    raise Http404
コード例 #2
0
    def post(self, request):
        student = StudentContainer(request.user)
        rq = RequestUtil()
        i = rq.get_student_info(request)
        context = {
            'countries': HomeUtil.get_countries(),
            'states': HomeUtil.get_states(),
            'programs': HomeUtil.get_student_programs(),
            'majors': HomeUtil.get_majors(),
        }
        if i:

            try:
                with transaction.atomic():
                    if student.new_student(i, request.user):
                        m = 'Student profile created successfully.'
                        MessageCenter.new_message('student',
                                                  student.get_student(),
                                                  'success', m)
                        return redirect('student:index')
                    else:
                        raise IntegrityError
            except IntegrityError:
                context['student'] = i
                context['errors'] = student.get_form().errors

        else:
            context['errors'] = rq.get_errors()

        return render(request, self.template_name, context)
コード例 #3
0
    def post(self, request):
        company = CompanyContainer(request.user)
        rq = RequestUtil()
        i = rq.get_company_info(request)
        context = {
            'company': company.get_company(),
            'countries': HomeUtil.get_countries(),
            'states': HomeUtil.get_states(),
            'tab': 'profile',
        }
        if i:

            try:
                with transaction.atomic():
                    if company.edit_company(i):
                        m = 'Company profile edited successfully.'
                        MessageCenter.new_message('company', company.get_company(), 'success', m)
                        return redirect('company:index')
                    else:
                        raise IntegrityError
            except IntegrityError:
                i['pk'] = '0'
                context['company'] = i
                context['errors'] = company.get_form().errors

        else:
            info = rq.get_info()
            info['pk'] = '0'
            context['company'] = info
            context['errors'] = rq.get_errors()

        return render(request, self.template_name, context)
コード例 #4
0
ファイル: views.py プロジェクト: madmax330/Jobin
def new_resume(request):

    if request.method == 'POST':
        student = StudentContainer(request.user)
        rq = RequestUtil()
        i = rq.get_resume_info(request)
        if i:

            try:
                with transaction.atomic():
                    if student.new_resume(i):
                        r = student.get_resume()
                        if r.is_complete:
                            m = 'New resume created successfully.'
                            MessageCenter.new_message('student', student.get_student(), 'success', m)
                            m = 'resume complete'
                            return HttpResponse(m, status=200)
                        else:
                            m = r.id
                            return HttpResponse(m, status=200)
                    else:
                        raise IntegrityError
            except IntegrityError:
                return HttpResponse(str(student.get_errors()), status=400)

        else:
            return HttpResponse(str(rq.get_errors()), status=400)

    raise Http404
コード例 #5
0
    def post(self, request, pk):
        company = CompanyContainer(request.user)
        rq = RequestUtil()
        i = rq.get_event_info(request)
        context = {
            'company': company.get_company(),
            'event': company.get_event(pk),
            'countries': HomeUtil.get_countries(),
            'states': HomeUtil.get_states(),
            'tab': 'events',
        }
        if i:

            try:
                with transaction.atomic():
                    if company.edit_event(pk, 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)
コード例 #6
0
    def post(self, request):

        rq = RequestUtil()
        context = {}
        obj = PublicObject('en')
        i = rq.get_contact_message_info(request)
        if i:
            if obj.new_message(i):
                context['message'] = {'success': 'Message sent successfully.'}
            else:
                context['error'] = obj.get_error_message()
                context['errors'] = obj.get_form_errors()
        else:
            context['errors'] = rq.get_errors()
        return render(request, self.template_name, context)
コード例 #7
0
    def post(self, request):

        rq = RequestUtil()
        context = {}
        i = rq.get_consult_request_info(request)
        context['info'] = rq.get_info()
        if i:
            obj = PublicObject('en')
            if obj.new_consult_request(i):
                context['message'] = {
                    'success': 'Consult Request sent successfully.'
                }
            else:
                context['error'] = obj.get_error_message()
                context['errors'] = obj.get_form_errors()
        context['errors'] = rq.get_errors()
        return render(request, self.template_name, context)
コード例 #8
0
ファイル: views.py プロジェクト: madmax330/bssmanager
def staff_upload_project_receipt_file(request, pk):
    if request.method == 'POST':

        obj = StaffObject(request.user)
        rq = RequestUtil()

        try:
            with transaction.atomic():
                if obj.upload_project_receipt_file(
                        pk, rq.get_receipt_file_info(request), request.FILES):
                    return JsonResponse(SUCCESS_DICT)
                else:
                    raise IntegrityError
        except IntegrityError as e:
            return JsonResponse(
                {
                    'status': 'error',
                    'error': obj.get_error_message() + '\n' + str(e)
                },
                status=200)

    raise Http404
コード例 #9
0
def new_suggestion(request):

    if request.method == 'POST':
        company = CompanyContainer(request.user)
        rq = RequestUtil()
        i = rq.get_suggestion_info(request)
        if i:

            try:
                with transaction.atomic():
                    if company.new_suggestion(i):
                        m = 'Suggestion successfully submitted.'
                        MessageCenter.new_message('company', company.get_company(), 'success', m)
                        return HttpResponse(status=200)
                    else:
                        raise IntegrityError
            except IntegrityError:
                return HttpResponse(str(company.get_errors()), status=400)

        else:
            return HttpResponse(str(rq.get_errors()), status=400)

    raise Http404
コード例 #10
0
def staff_new_staff_member(request):

    if request.method == 'POST':

        obj = StaffObject(request.user)
        rq = RequestUtil()

        try:
            with transaction.atomic():
                if obj.new_staff_member(rq.get_staff_profile_info(request)):
                    return JsonResponse(SUCCESS_DICT, status=200)
                else:
                    raise IntegrityError
        except IntegrityError as e:
            return JsonResponse(
                {
                    'status': 'error',
                    'error': obj.get_error_message() + '\n' + str(e),
                    'errors': obj.get_form_errors()
                },
                status=200)

    raise Http404
コード例 #11
0
 def post(self, request):
     rq = RequestUtil()
     i = rq.get_login_info(request)
     context = {
         'info': rq.get_info(),
         'language': request.GET.get('language', 'en')
     }
     if i:
         user = authenticate(username=i['username'], password=i['password'])
         if user is not None:
             if user.is_active:
                 if user.groups.filter(name='staff').exists():
                     login(request, user)
                     return redirect('home:staff_index_view')
                 elif user.groups.filter(name='client').exists():
                     login(request, user)
                     return redirect('home:index_view')
                 else:
                     context['error'] = 'Invalid user group.'
             context['error'] = 'User not active.'
         context['error'] = 'Invalid username or password.'
     context['errors'] = rq.get_errors()
     return render(request, self.template_name, context)
コード例 #12
0
ファイル: views.py プロジェクト: madmax330/bssmanager
def client_new_project_file(request, pk):

    if request.method == 'POST':

        obj = ClientObject(request.user)
        rq = RequestUtil()

        try:
            with transaction.atomic():
                if obj.new_project_file(pk, rq.get_file_info(request),
                                        request.FILES):
                    return JsonResponse(SUCCESS_DICT, status=200)
                else:
                    raise IntegrityError
        except IntegrityError as e:
            return JsonResponse(
                {
                    'status': 'error',
                    'error': obj.get_error_message() + '\n' + str(e),
                    'errors': obj.get_form_errors()
                },
                status=200)

    raise Http404
コード例 #13
0
def staff_new_hosting_access_key(request, pk):

    if request.method == 'POST':

        obj = StaffObject(request.user)
        rq = RequestUtil()

        try:
            with transaction.atomic():
                if obj.new_hosting_access_key(pk,
                                              rq.get_access_key_info(request),
                                              request.FILES):
                    return JsonResponse(SUCCESS_DICT, status=200)
                else:
                    raise IntegrityError
        except IntegrityError as e:
            return JsonResponse(
                {
                    'status': 'error',
                    'error': obj.get_error_message() + '\n' + str(e),
                },
                status=200)

    raise Http404