Example #1
0
def create_task(request, username):
    l = LeaderUser.objects.get(username__exact=username)
    if request.method == 'POST':
        form = CreateTaskForm(request.POST)
        if form.is_valid():
            mem_dat = form.cleaned_data.get('members')
            title = form.cleaned_data.get('title')
            est_end = form.cleaned_data.get('est_end')
            status = form.cleaned_data.get('status')
            lt = form.cleaned_data.get('to_leader')
            if lt is None:
                lt = False
            t = Task.objects.create(title=title,
                                    est_end=est_end,
                                    status=status,
                                    to_leader=lt,
                                    action_list=l.project.actionlist)
            t.save()

            for m in mem_dat:
                t.members.add(m)
            t.save()
            log('INFO', l,
                '{} added a new Task [{}]'.format(l.username, t.title))
            return redirect('leader_home', username)
        else:
            print(form.errors)
    else:
        form = CreateTaskForm({'pn': l.project.name})

    return render(request, 'crtask.html', {'form': form})
Example #2
0
 def Test_log_contains_warning_leader(self):
     l = LeaderUser.objects.get(first_name__exact='leader')
     p = l.project
     log('WARNING', l, 'leader log record')
     f = open(p.activitylog.content, 'r')
     logfile = f.readlines()[1]
     data = parse('[{}] [{}] [{}] [{}] [{}] [{}]', logfile)
     TestCase.assertEquals(self, data[0], 'WARNING')
     TestCase.assertEquals(self, data[1], l.get_full_name())
     TestCase.assertEquals(self, data[2], 'LEADER')
     TestCase.assertEquals(self, data[3], l.project.name)
     TestCase.assertEquals(self, data[5], 'leader log record')
     f.flush()
     f.close()
Example #3
0
 def Test_log_contains_info_member(self):
     m = MemberUser.objects.get(first_name__exact='Heracles')
     p = m.project
     log('INFO', m, 'test content')
     f = open(p.activitylog.content, 'r')
     logfile = f.readlines()[0]
     data = parse('[{}] [{}] [{}] [{}] [{}] [{}]', logfile)
     TestCase.assertEquals(self, data[0], 'INFO')
     TestCase.assertEquals(self, data[1], m.get_full_name())
     TestCase.assertEquals(self, data[2], 'MEMBER')
     TestCase.assertEquals(self, data[3], m.project.name)
     TestCase.assertEquals(self, data[5], 'test content')
     f.flush()
     f.close()
Example #4
0
def member_upload(request, username, task):
    t = Task.objects.get(title=task)
    if 'up_file' in request.FILES:
        t.deliverable = request.FILES['up_file']
        t.save()
        mail_kickoff(MemberUser.objects.get(username__exact=username),
                     t,
                     var=3)
        log('SUCCESS', MemberUser.objects.get(username__exact=username),
            '{} uploaded a deliverable for {}'.format(username, t.title))
        print(t.deliverable.url)
    else:
        print('No file!!')
    return redirect('task_list', username)
Example #5
0
 def get_form_kwargs(self):
     l = LeaderUser.objects.get(username__exact=self.request.user.username)
     t = Task.objects.get(pk=self.kwargs['pk'])
     up_flag = False
     up_name = ''
     if bool(t.deliverable):
         up_flag = True
         up_name = t.deliverable.name.split('/')[-1]
         t.status = 'Completed'
         t.save()
         log(
             'SUCCESS', l, '{} uploaded a deliverable to Task [{}]'.format(
                 l.username, t.title))
         mail_kickoff(l, t, var=3)
     p = self.request.get_full_path()
     self.success_url = '/'.join(p.split('/')[:-3]) + '/'
     kwargs = super(TaskUpdate, self).get_form_kwargs()
     kwargs['pn'] = l.project.name
     kwargs['up_flag'] = up_flag
     kwargs['up_name'] = up_name
     log('INFO', l,
         '{} made changes to Task [{}]'.format(l.username, t.title))
     return kwargs