예제 #1
0
def task_update_view(request, pk):
    task = get_object_or_404(Task, pk=pk)
    if request.method == 'GET':
        form = TaskForm(
            data={
                'description': task.description,
                'detailed_desc': task.detailed_desc,
                'status': task.status,
                'finish_date': task.finish_date,
            })
        return render(request,
                      'update.html',
                      context={
                          'form': form,
                          'task': task
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.description = form.cleaned_data['description']
            task.detailed_desc = form.cleaned_data['detailed_desc']
            task.status = form.cleaned_data['status']
            task.finish_date = form.cleaned_data['finish_date']
            task.save()
            return redirect(task_view, pk=task.pk)
        else:
            return render(request,
                          'update.html',
                          context={
                              'form': form,
                              'task': task
                          })
예제 #2
0
def tasks_add_view(request, *args, **kwargs):
    if request.method == 'GET':
        form = TaskForm()
        return render(request,
                      'create.html',
                      context={
                          'statuses': STATUS_CHOICES,
                          'form': form
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Tasks.objects.create(
                description=form.cleaned_data['description'],
                status=form.cleaned_data['status'],
                done_date=form.cleaned_data['done_date'],
                detailed_description=form.cleaned_data['detailed_description'],
            )
            return redirect('task_view', pk=task.pk)
        else:
            return render(request,
                          'create.html',
                          context={
                              'form': form,
                              'statuses': STATUS_CHOICES
                          })
def task_create_view(request, *args, **kwargs):
    if request.method == 'GET':

        form = TaskForm()

        return render(request, 'create.html', context={'form': form})

    elif request.method == 'POST':

        form = TaskForm(data=request.POST)

        if form.is_valid():

            article = Task.objects.create(

                description=form.cleaned_data['description'],

                date=form.cleaned_data['date'],

                text=form.cleaned_data['text'],

                status=form.cleaned_data['status']

            )

            return redirect('task_view', pk=article.pk)

        else:

            return render(request, 'create.html', context={'form': form})
예제 #4
0
def task_update_view(request, pk):
    task = get_object_or_404(Task, pk=pk)
    if request.method == 'GET':
        form = TaskForm(
            data={
                'description': task.description,
                'status': task.status,
                'date_perf': task.date_perf,
                'detail': task.detail
            })
        return render(request,
                      'update.html',
                      context={
                          'form': form,
                          'task': task
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.description = form.cleaned_data['description']
            task.status = form.cleaned_data['status']
            task.date_perf = form.cleaned_data['date_perf']
            task.detail = form.cleaned_data['detail']
            task.save()
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'create.html', context={'form': form})
예제 #5
0
파일: views.py 프로젝트: tyzo4ka/to_do_list
def task_update_view(request, pk):
    task = get_object_or_404(Task, pk=pk)
    if request.method == 'GET':
        form = TaskForm(
            data={
                "description": task.description,
                "detailed": task.detailed,
                "status": task.status,
                "complete_before": task.complete_before
            })
        return render(request,
                      "update.html",
                      context={
                          "form": form,
                          "task": task
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.description = form.cleaned_data["description"]
            task.detailed = form.cleaned_data["detailed"]
            task.status = form.cleaned_data["status"]
            task.complete_before = form.cleaned_data["complete_before"]
            task.save()
            return redirect("task_view", pk=task.pk)
        else:
            return render(request,
                          "update.html",
                          context={
                              "form": form,
                              "task": task
                          })
예제 #6
0
def task_update_view(request, pk):
    task = get_object_or_404(Tasks, pk=pk)
    print(task)
    if request.method == 'GET':
        form = TaskForm(
            data={
                'descr': task.descr,
                'status': task.status,
                'completion_date': task.completion_date,
                'full_description': task.full_description
            })
        return render(request,
                      'update.html',
                      context={
                          'form': form,
                          'task': task
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.descr = form.cleaned_data['descr']
            task.status = form.cleaned_data['status']
            task.completion_date = form.cleaned_data['completion_date']
            task.full_description = form.cleaned_data['full_description']
            task.save()
            return redirect('task', pk=task.pk)
        else:
            return render(request,
                          'update.html',
                          context={
                              'form': form,
                              'task': task
                          })
예제 #7
0
def task_update_view(request, pk):
    task = get_object_or_404(Task, pk=pk)
    if request.method == 'GET':
        form = TaskForm(
            data={
                'description': task.description,
                'specific': task.specific,
                'status': task.status,
                'date_of_completion': task.date_of_completion
            })
        return render(request,
                      'update.html',
                      context={
                          'form': form,
                          'task': task,
                          'status_choises': STATUS_CHOISES
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.description = form.cleaned_data['description']
            task.specific = form.cleaned_data['specific']
            task.status = form.cleaned_data['status']
            task.date_of_completion = form.cleaned_data['date_of_completion']
            task.save()
            return redirect('task_view', pk=task.pk)
        else:
            return render(request,
                          'update.html',
                          context={
                              'form': form,
                              'task': task,
                              'status_choises': STATUS_CHOISES
                          })
예제 #8
0
def task_create_view(request):
    if request.method == "GET":
        form = TaskForm()
        return render(request,
                      'create.html',
                      context={
                          'status_choises': STATUS_CHOISES,
                          'form': form
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Task.objects.create(
                description=form.cleaned_data['description'],
                specific=form.cleaned_data['specific'],
                status=form.cleaned_data['status'],
                date_of_completion=form.cleaned_data['date_of_completion'])
            return redirect('task_view', pk=task.pk)

        else:
            return render(request,
                          'create.html',
                          context={
                              'status_choises': STATUS_CHOISES,
                              'form': form
                          })
예제 #9
0
def task_update_view(request, pk):
    task = get_object_or_404(Article, pk=pk)
    if request.method == 'GET':
        form = TaskForm(
            data={
                'title': task.description,
                'author': task.full_description,
                'text': task.status,
                'category': task.finish_at
            })
        return render(request,
                      'update.html',
                      context={
                          'form': form,
                          'task': task
                      })

    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.description = form.cleaned_data['description']
            task.full_description = form.cleaned_data['full_description']
            task.status = form.cleaned_data['status']
            task.finish_at = form.cleaned_data['finish_at']
            task.save()
            return redirect('task_view', pk=task.pk)
        else:
            return render(request,
                          'update.html',
                          context={
                              'form': form,
                              'task': task
                          })
예제 #10
0
def create(request, group_id, set_id):
    group, role = item_is_staff('group', request.user, group_id)

    rd = redirect('staff_group_tasks', group_id=group_id)

    if group.archived:
        messages.warning(request, 'Task cannot be added to archived group.')
        return rd

    try:
        task_set = TaskGroupSet.objects.get(pk=set_id)
    except TaskGroupSet.DoesNotExist:
        messages.warning(request,
                         'Task cannot be added to nonexistent task set.')
        return rd

    if request.method == 'POST':
        instance = Task(owner=request.user, task_group=group, tg_set=task_set)
        form = TaskForm(request.POST, request.FILES, instance=instance)
        if form.is_valid():
            form.save()
            return rd
        messages.error(request, 'Form was filled incorrectly')
    else:
        form = TaskForm()

    context = {
        'form': form,
        'group': group,
        'set': task_set,
        'title': 'Create task'
    }
    return render(request, 'webapp/admin/task/actions.html', context)
 def post(self, request, *args, **kwargs):
     form = TaskForm(data=request.POST)
     if form.is_valid():
         Task.objects.create(summary=form.cleaned_data['summary'],
                             description=form.cleaned_data['description'],
                             status=form.cleaned_data['status'],
                             type=form.cleaned_data['type'])
         return redirect('webapp:index')
     else:
         return render(request, 'task/create.html', context={'form': form})
예제 #12
0
def task_create(request):
    # if this is a POST request we need to process the form data
    if request.method == 'POST':
        form = TaskForm(request.POST, request.FILES)
        # check whether it's valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required
            # ...
            # redirect to a new URL:
            return HttpResponseRedirect(reverse('home'))
    else:
        form = TaskForm()
    return render(request, 'webapp/task_create.html', {'form': form})
예제 #13
0
def task_create_view(request):
    if request.method == 'GET':
        form = TaskForm()
        return render(request, 'add.html', {'form': form})
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Task.objects.create(
                description=form.cleaned_data['description'],
                status=form.cleaned_data['status'],
                detailed_desc=form.cleaned_data['detailed_desc'],
                finish_date=form.cleaned_data['finish_date'])
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'add.html', {'form': form})
예제 #14
0
파일: views.py 프로젝트: tyzo4ka/to_do_list
def task_create_view(request, *args, **kwargs):
    if request.method == 'GET':
        form = TaskForm()
        return render(request, 'create.html', context={"form": form})
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Task.objects.create(
                description=form.cleaned_data["description"],
                detailed=form.cleaned_data["detailed"],
                status=form.cleaned_data["status"],
                complete_before=form.cleaned_data["complete_before"])
            return redirect("task_view", pk=task.pk)
        else:
            return render(request, "create.html", context={"form": form})
예제 #15
0
def task_create_view(request, *args, **kwargs):
    if request.method == 'GET':
        form = TaskForm()
        return render(request, 'create.html', context={'form': form})
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Tasks.objects.create(
                descr=form.cleaned_data['descr'],
                status=form.cleaned_data['status'],
                full_description=form.cleaned_data['full_description'],
                completion_date=form.cleaned_data['completion_date'])
            return redirect('task', pk=task.pk)
        else:
            return render(request, 'create.html', context={'form': form})
예제 #16
0
def task_edit_view(request, pk):
    task = get_object_or_404(Tasks, pk=pk)
    if request.method == 'GET':
        form = TaskForm()
        return render(request, 'update.html', context={'task': task,'form': form})
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.title = request.POST.get('title')
            task.status = request.POST.get('status')
            task.description = request.POST.get('description')
            task.created_at = request.POST.get('created_at')
            task.save()
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'update.html', context={'task': task, 'form': form})
    return redirect('task_view', pk=task.pk)
 def post(self, request, *args, **kwargs):
     task_pk = kwargs.get('pk')
     task = get_object_or_404(Task, pk=task_pk)
     form = TaskForm(data=request.POST)
     if form.is_valid():
         task.summary = form.cleaned_data['summary']
         task.description = form.cleaned_data['description']
         task.status = form.cleaned_data['status']
         task.type = form.cleaned_data['type']
         task.save()
         return redirect('webapp:index')
     else:
         return render(request,
                       'task/update.html',
                       context={
                           'form': form,
                           'task': task
                       })
예제 #18
0
def task_create_view(request, *args, **kwargs):
    if request.method == 'GET':
        form = TaskForm()
        print('create')
        print(form)
        return render(request, 'create.html', context={'form': form})
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Tasks.objects.create(
                title=form.cleaned_data['title'],
                status=form.cleaned_data['status'],
                description=form.cleaned_data['description'],
                created_at=form.cleaned_data['created_at']
            )
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'create.html', context={'form': form})
예제 #19
0
def task_create_view(request):
    if request.method == 'GET':
        form = TaskForm()
        return render(request,
                      'create.html',
                      context={
                          'status_choices': STATUS_CHOICES,
                          'form': form
                      })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task = Article.objects.create(
                description=form.cleaned_data['description'],
                full_description=form.cleaned_data['full_description'],
                status=form.cleaned_data['status'],
                finish_at=form.cleaned_data['finish_at'])
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'create.html', context={'form': form})
예제 #20
0
def show_list(request, name):

    account = request.user.get_profile()
    lst = lists.get_list(name, account)

    if request.method == 'POST':
        form = TaskForm(request.POST)
        if form.is_valid():
            text = form.cleaned_data['text']
            lst.add_task(text)
            return HttpResponseRedirect(reverse('webapp.lists.views.show_list', args=[name]))
        else:
            return render_to_response('lists/list.html', {
                    'form' : form,
                    'lst' : lst,
                    }, context_instance = RequestContext(request))
    else:
        return render_to_response('lists/list.html', {
                'form' : TaskForm(),
                'lst' : lst,
                }, context_instance = RequestContext(request))
예제 #21
0
    def post(self, request, *args, **kwargs):
        task_id = request.POST.get('task_parent')
        category_id = request.POST.get('category')
        if task_id and category_id:
            task = Task.objects.get(pk=int(task_id))
            category = Category.objects.get(pk=int(category_id))
        else:
            task = None
            category = None
        form = TaskForm(request.POST)
        if form.is_valid():
            Task.objects.create(
                assigned_to=request.user,
                title=form.cleaned_data['title'],
                category=category,
                parent_task=task
            )

            return redirect('/')
        tasks = Task.objects.filter(assigned_to=request.user)
        context = {'tasks': tasks, 'form': form}
        return render(request, 'index.html', context)
예제 #22
0
def task_update_view(request, pk):
    task = get_object_or_404(To_Do_list, pk=pk)
    if request.method == "GET":
        form = TaskForm(data={
            'status': task.status,
            'summary': task.summary,
            'description': task.description,
            'completion_time': task.completion_time
        })
        return render(request, 'task_update.html', context={'form': form, 'task': task})
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            task.status = form.cleaned_data['status']
            task.summary = form.cleaned_data['summary']
            task.description = form.cleaned_data['description']
            task.completion_time = form.cleaned_data['completion_time']
            task.save()
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'task_update.html', context={'task': task, 'form': form})
    else:
        return HttpResponseNotAllowed(permitted_methods=['GET', 'POST'])
예제 #23
0
def task_create_view(request, *args, **kwargs):
    if request.method == "GET":
        return render(request, 'task_create.html', context={
            'form': TaskForm()
        })
    elif request.method == 'POST':
        form = TaskForm(data=request.POST)
        if form.is_valid():
            summary = form.cleaned_data['summary']
            description = form.cleaned_data['description']
            status = form.cleaned_data['status']
            completion_time = form.cleaned_data['completion_time']
            if completion_time:
                task = To_Do_list.objects.create(summary=summary, description=description,
                                                 completion_time=completion_time,
                                                 status=status)
            else:
                task = To_Do_list.objects.create(summary=summary, description=description,
                                                 status=status)
            return redirect('task_view', pk=task.pk)
        else:
            return render(request, 'task_create.html', context={'form': form})
    else:
        return HttpResponseNotAllowed(permitted_methods=['GET', 'POST'])