Beispiel #1
0
 def post(self, request, *args, **kwargs):
     job = get_object_or_404(Job, random_string=kwargs['job_random_string'])
     form = self.form(request.POST)
     if (form.is_valid()):
         jobuser = get_object_or_None(JobUser, user=request.user, job=job)
         amount = float(form.cleaned_data['amount'])
         if (jobuser):
             jobuser.pledging = jobuser.pledging + amount
         else:
             jobuser = JobUser.create(user=request.user,
                                      job=job,
                                      pledging=amount)
         jobuser.save()
         pledge = Pledge.create(jobuser=jobuser, amount=amount)
         pledge.save()
         comment = form.cleaned_data['comment']
         if (comment):
             update = Update.create(jobuser=jobuser, comment=comment)
             update.save()
         job.pledging = job.pledging + amount
         job.save()
         sendNotifications(jobuser)
         return redirect('job:detail', job_random_string=job.random_string)
     else:
         return render(request, self.template_name,
                       self.get_context_data(job=job, form=form))
Beispiel #2
0
 def post(self, request, *args, **kwargs):
     job = get_object_or_404(Job, random_string=kwargs['job_random_string'])
     form = self.form(request.POST)
     jobuser = get_object_or_None(JobUser, user=request.user, job=job)
     if (jobuser and jobuser.work_set.all().exists()):
         return redirect('job:detail', job_random_string=job.random_string)
     elif (form.is_valid()):
         print("Form is valid")
         if (jobuser):
             jobuser.work_status = 'Working'
         else:
             jobuser = JobUser(user=request.user,
                               job=job,
                               work_status='Working')
         jobuser.save()
         work = Work.create(jobuser=jobuser, )
         work.save()
         comment = form.cleaned_data['comment']
         if (comment):
             update = Update.create(jobuser=jobuser, comment=comment)
             update.save()
         job.working = job.working + 1
         job.save()
         sendNotifications(jobuser)
         return redirect('job:detail', job_random_string=job.random_string)
     else:
         return render(request, self.template_name,
                       self.get_context_data(job=job, form=form))
Beispiel #3
0
 def post(self, request, *args, **kwargs):
     job = get_object_or_404(Job, random_string=kwargs['job_random_string'])
     receiver = get_object_or_None(JobUser, user=request.user, job=job)
     payments = MiscPay.objects.filter(receiver=receiver,
                                       confirmed='Unconfirmed')
     confirm_or_reject = ""
     pk = ""
     for p in payments:
         if (str(p.pk) in request.POST):
             pk = p.pk
             confirm_or_reject = request.POST[str(p.pk)]
     misc_pay = get_object_or_None(MiscPay, pk=pk)
     if (misc_pay):
         if (confirm_or_reject == 'Confirm'):
             misc_pay.confirmed = 'Confirmed'
             receiver.misc_paid = receiver.misc_paid + misc_pay.amount
             receiver.received = receiver.received + misc_pay.amount
             receiver.save()
             misc_pay.jobuser.misc_paid = misc_pay.jobuser.misc_paid + misc_pay.amount
             misc_pay.jobuser.received = misc_pay.jobuser.received + misc_pay.amount
             misc_pay.jobuser.save()
             job.paid = job.paid + misc_pay.amount
             job.receiver = job.received + misc_pay.amount
             #if (job.set_is_finished()):
             #    job.is_finished = True;
             job.save()
         else:
             misc_pay.confirmed = 'Rejected'
         misc_pay.save()
         sendNotifications(receiver)
         return redirect('job:confirm-pay',
                         job_random_string=job.random_string)
     else:
         return render(request, self.template_name,
                       self.get_context_data(jobuser=jobuser))
Beispiel #4
0
 def post(self, request, *args, **kwargs):
     job = get_object_or_404(Job, random_string=kwargs['job_random_string'])
     form = self.form(request.POST)
     if (form.is_valid()):
         comment = form.cleaned_data['comment']
         if (comment != "" or len(request.FILES) > 0):
             jobuser = JobUser.objects.get(user=request.user, job=job)
             update = Update.create(jobuser=jobuser, comment=comment)
             update.save()
             for image in request.FILES.getlist('images'):
                 image = Image(update=update, image=image)
                 image.save()
             sendNotifications(jobuser)
         return redirect('job:detail', job_random_string=job.random_string)
     else:
         return render(request, self.template_name,
                       self.get_context_data(job=job, form=form))
Beispiel #5
0
 def post(self, request, *args, **kwargs):
     job = get_object_or_404(Job, random_string=kwargs['job_random_string'])
     form = self.form(request.POST)
     if (form.is_valid()):
         jobuser = get_object_or_None(JobUser, user=request.user, job=job)
         jobuser.work_status = 'Finished'
         jobuser.save()
         finish = Finish.create(jobuser=jobuser)
         finish.save()
         comment = form.cleaned_data['comment']
         if (comment):
             update = Update(jobuser=jobuser, comment=comment)
             update.save()
         job.finished = job.finished + 1
         #if (job.get_is_finished()):
         #    job.set_is_finished(True);
         job.save()
         sendNotifications(jobuser)
         return redirect('job:detail', job_random_string=job.random_string)
     else:
         return render(request, self.template_name,
                       self.get_context_data(job=job, form=form))