Beispiel #1
0
def new_task(request):
	if (request.method != 'POST'):
		return err_GE002()
	form = NewTaskForm(request.POST)
	if (not form.is_valid()):
		return err_GE031(form)

	local_tz = timezone(settings.TIME_ZONE)

	task = FollowUps(
			user=request.user,
			due_date=timezone_conversion(
									form.cleaned_data['due'],
									local_tz,
									).replace(tzinfo=None),
			priority=form.cleaned_data['priority'],
			task=form.cleaned_data['description'],
			note=form.cleaned_data['note'],
		)

	task.save()

	response = {
		'data': {'id': task.id},
		'warnings': {},
	}
	return HttpResponse(content=json.dumps(response), mimetype='application/json')
Beispiel #2
0
def new_task(request):
    if (request.method != 'POST'):
        return err_GE002()
    form = NewTaskForm(request.POST)
    if (not form.is_valid()):
        return err_GE031(form)

    local_tz = timezone(settings.TIME_ZONE)

    task = FollowUps(
        user=request.user,
        due_date=timezone_conversion(
            form.cleaned_data['due'],
            local_tz,
        ).replace(tzinfo=None),
        priority=form.cleaned_data['priority'],
        task=form.cleaned_data['description'],
        note=form.cleaned_data['note'],
    )

    task.save()

    response = {
        'data': {
            'id': task.id
        },
        'warnings': {},
    }
    return HttpResponse(content=json.dumps(response),
                        mimetype='application/json')
	def testDeleteTask(self):
		task = FollowUps(user=self.user, priority=1)
		task.save()
		response = self.client.post(reverse(
			'MHLogin.api.v1.views_followups.deleteTask',args=(task.id,)), **self.extra)
		self.assertEqual(response.status_code, 200, response.status_code)
		msg = json.loads(response.content)
		self.assertEqual(len(msg), 2)
Beispiel #4
0
 def testDeleteTask(self):
     task = FollowUps(user=self.user, priority=1)
     task.save()
     response = self.client.post(
         reverse('MHLogin.api.v1.views_followups.deleteTask',
                 args=(task.id, )), **self.extra)
     self.assertEqual(response.status_code, 200, response.status_code)
     msg = json.loads(response.content)
     self.assertEqual(len(msg), 2)
 def testDeleteFollowUp(self):
     with self.assertRaises(Http404):
         deleteFollowUp(1, self.user.id)
     task = FollowUps(user=self.user, priority=1)
     task.save()
     deleteFollowUp(task.id, self.user.id)
     with self.assertRaises(FollowUps.DoesNotExist):
         FollowUps.objects.get(pk=task.id)
     with self.assertRaises(ValueError):
         deleteFollowUp('ab', 'cd')
Beispiel #6
0
def createFollowUp(data_dict, user_id):
	task = FollowUps(
			user_id=user_id,
			due_date=timezone_conversion(
									data_dict['due'],
									timezone(settings.TIME_ZONE),
									).replace(tzinfo=None),
			priority=data_dict['priority'],
			task=data_dict['description'],
			note=data_dict['note'],
		)
	task.save()
	return task
Beispiel #7
0
def createFollowUp(data_dict, user_id):
    task = FollowUps(
        user_id=user_id,
        due_date=timezone_conversion(
            data_dict['due'],
            timezone(settings.TIME_ZONE),
        ).replace(tzinfo=None),
        priority=data_dict['priority'],
        task=data_dict['description'],
        note=data_dict['note'],
    )
    task.save()
    return task
	def test_delete_task(self):
		task_id = 0
		request = generateHttpRequest()

		#invalid task id
		try:
			delete_task(request, task_id)
		except Http404:
			self.assertRaises(Http404())

		#valid task id
		task = FollowUps(user=request.user, priority=1)
		task.save()
		result = delete_task(request, task.pk)
		self.assertEqual(result.status_code, 200)
		self.assertEqual(FollowUps.objects.count(), 0)
Beispiel #9
0
    def test_delete_task(self):
        task_id = 0
        request = generateHttpRequest()

        #invalid task id
        try:
            delete_task(request, task_id)
        except Http404:
            self.assertRaises(Http404())

        #valid task id
        task = FollowUps(user=request.user, priority=1)
        task.save()
        result = delete_task(request, task.pk)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(FollowUps.objects.count(), 0)
Beispiel #10
0
 def testUpdateFollowUp(self):
     task = FollowUps(user=self.user, priority=1)
     task.save()
     self.assertFalse(task.done)
     data = {
         'priority': 10,
         'description': 'this is followUps',
         'completed': True
     }
     updateFollowUp(data, task.id, self.user.id)
     try:
         task = FollowUps.objects.get(pk=task.id)
         task.save()
     except:
         FollowUps.DoesNotExist
     self.assertTrue(task.done)