コード例 #1
0
ファイル: tests.py プロジェクト: vitorh45/drest
class TaskModelTest(TestCase):
    def setUp(self):
        self.obj = Task(name="Task teste 1", is_done=False)

    def test_create(self):
        self.obj.save()
        self.assertEqual(1, self.obj.pk)
コード例 #2
0
ファイル: test_views.py プロジェクト: tnakamura/SilverTask
    def test_delete(self):
        key = Task(name="fuga").put()
        tasks = Task.all().fetch(100)
        self.assertEquals(1, len(tasks))

        response = self.client.delete('/tasks/%s' % key, follow_redirects=True)
        tasks = Task.all().fetch(100)
        self.assertEquals(0, len(tasks))
コード例 #3
0
ファイル: test_models.py プロジェクト: tnakamura/SilverTask
    def test_create_task(self):
        data = {
            "name": "foo",
        }
        t = Task.create_task(data)
        self.assertEquals("foo", t.name)

        tasks = Task.all().fetch(100)
        self.assertEquals("foo", tasks[0].name)
コード例 #4
0
ファイル: views.py プロジェクト: tnakamura/SilverTask
def tasks(request):
    if request.method == "POST":
        task = Task.create_task(request.form)
        return render_json_response(task.to_dict())

    tasks = Task.read_tasks(request.user.key(),
                            params=request.args)
    data = [task.to_dict() for task in tasks]
    return render_json_response(data)
コード例 #5
0
ファイル: test_models.py プロジェクト: tnakamura/SilverTask
    def test_to_dict(self):
        t = Task(name="foo")
        key = t.put()

        task = Task.get(key)
        dic = task.to_dict()

        self.assertEquals(str(key), dic["key"])
        self.assertEquals("foo", dic["name"])
        self.assertEquals(False, dic["done"])
コード例 #6
0
ファイル: views.py プロジェクト: tnakamura/SilverTask
def task_detail(request, key):
    if request.method == "DELETE":
        Task.delete_task(key)
        return Response(key)

    if request.method == "PUT":
        model_dict = simplejson.load(request.stream)
        task = Task.update_task(key, model_dict)
    else:
        task = get_or_404(Task, key)
    return render_json_response(task.to_dict())
コード例 #7
0
ファイル: test_views.py プロジェクト: tnakamura/SilverTask
    def test_put(self):
        key = Task(name="hoge").put()
        tasks = Task.all().fetch(100)
        self.assertEquals(1, len(tasks))

        input_stream = StringIO('{ "name" : "fuga" }')
        response = self.client.put('/tasks/%s' % key,
                input_stream=input_stream,
                follow_redirects=True)

        actual = Task.get(key)
        self.assertEquals("fuga", actual.name)
コード例 #8
0
ファイル: test_views.py プロジェクト: tnakamura/SilverTask
 def test_post(self):
     data = {
         "name": "foo",
     }
     response = self.client.post('/tasks', data=data, follow_redirects=True)
     actual = Task.all().get()
     self.assertEquals("foo", actual.name)
コード例 #9
0
def populate():
    actions = [
        'Купить',
        'Продать',
        'Принести',
        'Отдать',
        'Забрать',
        'Сделать',
    ]
    goods = [
        'молоко',
        'хлеб',
        'телефон',
        'шкаф',
        'рюкзак',
        'ключ',
    ]
    todolist = []
    items_qty = random.randint(3, 6)
    count = 0
    while (count < items_qty):
        todo_item = ' '.join([random.choice(actions), random.choice(goods)])
        if todo_item not in todolist:
            todolist.append(todo_item)
            count += 1
    for item in todolist:
        Task(title=item).save()
コード例 #10
0
 def insert(self, entity: Task):
     if entity:
         entity.id = self.db.exec_ins(self._insert_sql(entity))
         for i in entity.items:
             i.task_id = entity.id
             self.db.repoTaskItem.insert(i)
         return entity.id
     return None
コード例 #11
0
ファイル: tests.py プロジェクト: CodeTag/taximetracker
    def test_al_detener_tarea_con_campo_de_tarea_vacio_para_no_detener_tarea_ni_crear_proyecto(self):
        user = User.objects.create(username="******",password="******")

        tk = Task(user=user, name='in_progress', started=True, project=None)
        tk.start()

        factory = RequestFactory()

        request = factory.post("/fasttask")
        request.user = user
        request.POST["taskName"] = ""
        request.POST["newProjectName"] = "Project1"
        request.POST["choisebuttom"] = "Stop"

        fast_task(request)

        tasks_stopped = Task.objects.filter(started=False).count()
        projects_number = Project.objects.all().count()
        self.assertEqual(tasks_stopped+projects_number,0)
コード例 #12
0
    def _map(self, t: tuple) -> Task:
        r = Task()
        r.id = t[0]
        r.date = t[1]
        r.title = t[2]
        r.description = t[3]

        r.items = self.db.repoTaskItem.get_for_parent(r)

        return r
コード例 #13
0
ファイル: test_models.py プロジェクト: tnakamura/SilverTask
    def test_delete_task(self):
        t = Task(name="bar")
        key = t.put()
        tasks = Task.all().fetch(100)
        self.assertEquals(1, len(tasks))

        Task.delete_task(key)
        tasks = Task.all().fetch(100)
        self.assertEquals(0, len(tasks))
コード例 #14
0
ファイル: test_models.py プロジェクト: tnakamura/SilverTask
    def test_update_task(self):
        t = Task(name="hoge")
        key = t.put()
        tasks = Task.all().fetch(100)
        self.assertEquals(1, len(tasks))

        data = {
            "name": "fuga",
        }
        Task.update_task(key, data)
        actual = Task.all().get()
        self.assertEquals("fuga", actual.name)
コード例 #15
0
ファイル: views.py プロジェクト: pet-pal-project/petpal
def add_checklist(request, pk):
    pet = get_object_or_404(Pet, pk=pk)
    if request.method == 'POST':
        form = ChecklistForm2(request.POST)
        sitterform = UserForm(request.POST, user=request.user)
        if form.is_valid() and sitterform.is_valid():
            start_date = form.cleaned_data.get('start_date')
            end_date = form.cleaned_data.get('end_date')
            sitter = sitterform.cleaned_data.get('sitter') 
            task1 = request.POST['task1']
            task2 = request.POST['task2']
            task3 = request.POST['task3']
            task4 = request.POST['task4']
            task5 = request.POST['task5']
            task6 = request.POST['task6']
            task7 = request.POST['task7']
            task8 = request.POST['task8']
            task9 = request.POST['task9']
            task10 = request.POST['task10']
            print (start_date)
            print (end_date)
            delta = end_date - start_date
            print(delta.days)
            existing_visit = Visit.objects.filter(sitter_id=sitter).filter(due_date_on=start_date)
            num_of_days = delta.days
            if delta.days == 0:
                if existing_visit:
                    visitpk = existing_visit[0]
                    Checklist.objects
                    existing_checklist = Checklist.objects.filter(visit=visitpk).filter(pet_id=pet)
                    
                    if existing_checklist:
                        checklist = existing_checklist[0]
                    else:
                        checklist = Checklist(visit=visitpk, pet_id=pet)
                        checklist.save()

                    if task1:
                        new_task1 = Task(description=task1, checklist_id=checklist)
                        new_task1.save()
                    if task2:
                        new_task2 = Task(description=task2, checklist_id=checklist)
                        new_task2.save()
                    if task3:
                        new_task3 = Task(description=task3, checklist_id=checklist)
                        new_task3.save()
                    if task4:
                        new_task4 = Task(description=task4, checklist_id=checklist)
                        new_task4.save()
                    if task5:
                        new_task5 = Task(description=task5, checklist_id=checklist)
                        new_task5.save()
                    if task6:
                        new_task6 = Task(description=task6, checklist_id=checklist)
                        new_task6.save()
                    if task7:
                        new_task7 = Task(description=task7, checklist_id=checklist)
                        new_task7.save()
                    if task8:
                        new_task8 = Task(description=task8, checklist_id=checklist)
                        new_task8.save()
                    if task9:
                        new_task9 = Task(description=task9, checklist_id=checklist)
                        new_task9.save()
                    if task10:
                        new_task10 = Task(description=task10, checklist_id=checklist)
                        new_task10.save()
                  

                    print("EXISTING VISIT WITH DATE AND USER")
                else:
                    new_visit = Visit(sitter_id=sitter, due_date_on=start_date)    
                    new_visit.save()
                    visit_id = new_visit.pk
                    new_checklist = Checklist(visit=new_visit, pet_id=pet)
                    new_checklist.save()

                    if task1:
                        new_task1 = Task(description=task1, checklist_id=new_checklist)
                        new_task1.save()
                    if task2:
                        new_task2 = Task(description=task2, checklist_id=new_checklist)
                        new_task2.save()
                    if task3:
                        new_task3 = Task(description=task3, checklist_id=new_checklist)
                        new_task3.save()
                    if task4:
                        new_task4 = Task(description=task4, checklist_id=new_checklist)
                        new_task4.save()
                    if task5:
                        new_task5 = Task(description=task5, checklist_id=new_checklist)
                        new_task5.save()
                    if task6:
                        new_task6 = Task(description=task6, checklist_id=new_checklist)
                        new_task6.save()
                    if task7:
                        new_task7 = Task(description=task7, checklist_id=new_checklist)
                        new_task7.save()
                    if task8:
                        new_task8 = Task(description=task8, checklist_id=new_checklist)
                        new_task8.save()
                    if task9:
                        new_task9 = Task(description=task9, checklist_id=new_checklist)
                        new_task9.save()
                    if task10:
                        new_task10 = Task(description=task10, checklist_id=new_checklist)
                        new_task10.save()
                    print("A NEW VISIT WITH DATE AND USER")
            else:
                for day in range(num_of_days+1):
                    print("MORE THAN ONE DAY!")
                    
                    current_date = start_date + datetime.timedelta(days=day)
                    print(current_date)
                    existing_visit = Visit.objects.filter(sitter_id=sitter).filter(due_date_on=current_date)
                
                    if existing_visit:
                        print("EXISTING VISIT")
                        visitpk = existing_visit[0]
                        print(visitpk)
                        Checklist.objects
                        existing_checklist = Checklist.objects.filter(visit=visitpk).filter(pet_id=pet)

                        if existing_checklist:
                            checklist = existing_checklist[0]
                        else:
                            checklist = Checklist(visit=visitpk, pet_id=pet)
                            checklist.save()

                        if task1:
                            new_task1 = Task(description=task1, checklist_id=checklist)
                            new_task1.save()
                        if task2:
                            new_task2 = Task(description=task2, checklist_id=checklist)
                            new_task2.save()
                        if task3:
                            new_task3 = Task(description=task3, checklist_id=checklist)
                            new_task3.save()
                        if task4:
                            new_task4 = Task(description=task4, checklist_id=checklist)
                            new_task4.save()
                        if task5:
                            new_task5 = Task(description=task5, checklist_id=checklist)
                            new_task5.save()
                        if task6:
                            new_task6 = Task(description=task6, checklist_id=checklist)
                            new_task6.save()
                        if task7:
                            new_task7 = Task(description=task7, checklist_id=checklist)
                            new_task7.save()
                        if task8:
                            new_task8 = Task(description=task8, checklist_id=checklist)
                            new_task8.save()
                        if task9:
                            new_task9 = Task(description=task9, checklist_id=checklist)
                            new_task9.save()
                        if task10:
                            new_task10 = Task(description=task10, checklist_id=checklist)
                            new_task10.save()
                            print("SAME DAY")
                    else:
                        new_visit = Visit(sitter_id=sitter, due_date_on=current_date)    
                        new_visit.save()
                        visit_id = new_visit.pk
                        new_checklist = Checklist(visit=new_visit, pet_id=pet)
                        new_checklist.save()
                        if task1:
                            new_task1 = Task(description=task1, checklist_id=new_checklist)
                            new_task1.save()
                        if task2:
                            new_task2 = Task(description=task2, checklist_id=new_checklist)
                            new_task2.save()
                        if task3:
                            new_task3 = Task(description=task3, checklist_id=new_checklist)
                            new_task3.save()
                        if task4:
                            new_task4 = Task(description=task4, checklist_id=new_checklist)
                            new_task4.save()
                        if task5:
                            new_task5 = Task(description=task5, checklist_id=new_checklist)
                            new_task5.save()
                        if task6:
                            new_task6 = Task(description=task6, checklist_id=new_checklist)
                            new_task6.save()
                        if task7:
                            new_task7 = Task(description=task7, checklist_id=new_checklist)
                            new_task7.save()
                        if task8:
                            new_task8 = Task(description=task8, checklist_id=new_checklist)
                            new_task8.save()
                        if task9:
                            new_task9 = Task(description=task9, checklist_id=new_checklist)
                            new_task9.save()
                        if task10:
                            new_task10 = Task(description=task10, checklist_id=new_checklist)
                            new_task10.save()
                        print("DIFFERENT DAYS")



            
            return redirect('home')
    else:
        form = ChecklistForm2()
        sitterform = UserForm(user=request.user)

        
    return render(request, 'add_checklist.html', {'form': form, 'pet' : pet, 'sitterform': sitterform})
コード例 #16
0
 def act_task_new(self):
     self.act_task(Task())
コード例 #17
0
ファイル: views.py プロジェクト: CodeTag/taximetracker
def create_task(request, project):
    task_name = request.POST.get("taskname")
    task_description = request.POST.get("taskdescription")
    t = Task(name=task_name, description=task_description, user=request.user, project=project)
    t.save()
コード例 #18
0
ファイル: tests.py プロジェクト: vitorh45/drest
 def setUp(self):
     self.obj = Task(name="Task teste 1", is_done=False)
コード例 #19
0
def send_acknowldgement_email(book, press_editors):
    from_email = Setting.objects.get(
        group__name='email',
        name='from_address',
    ).value
    author_text = Setting.objects.get(
        group__name='email',
        name='author_submission_ack',
    ).value
    editor_text = Setting.objects.get(
        group__name='email',
        name='editor_submission_ack',
    ).value
    press_name = Setting.objects.get(
        group__name='general',
        name='press_name',
    ).value

    try:
        principal_contact_name = Setting.objects.get(
            group__name='general', name='primary_contact_name').value
    except:
        principal_contact_name = None

    context = {
        'base_url': Setting.objects.get(
            group__name='general',
            name='base_url',
        ).value,
        'submission': book,
        'press_name': press_name,
        'principal_contact_name': principal_contact_name,
    }

    email.send_email(
        get_setting('submission_ack_subject', 'email_subject',
                    'Submission Acknowledgement'),
        context,
        from_email,
        book.owner.email,
        author_text,
        book=book,
        kind='submission',
    )

    if len(press_editors) > 1:
        editor = press_editors[0]
        cc_eds = [ed.email for ed in press_editors if ed != press_editors[0]]
    else:
        editor = press_editors[0]
        cc_eds = None

    email.send_email(
        get_setting('new_submission_subject', 'email_subject',
                    'New Submission'),
        context,
        from_email,
        editor.email,
        editor_text,
        book=book,
        cc=cc_eds,
        kind='submission',
    )

    for editor in press_editors:
        notification = Task(
            book=book,
            assignee=editor,
            creator=press_editors[0],
            text='A new submission, {0}, has been made.'.format(book.title),
            workflow='review')
        notification.save()