Esempio n. 1
0
 def get_object(self, queryset=None):
     task_slug = self.kwargs.get('slug')
     user = self.request.user
     task_objs = TaskResult.objects.filter(user=user, task__slug=task_slug)
     if not task_objs.exists():
         raise Http404
     task = task_objs.order_by('-created')[0]
     return getattr(task, 'task%sresult' % slugify(unicode(task.task.slug)))
Esempio n. 2
0
def do_task_view(request, slug):
    user = request.user
    try:
        task = TaskInfo.objects.get(slug=slug)
    except TaskInfo.DoesNotExist:
        raise Http404
    try:
        eval('Task%sResultForm' % slugify(unicode(task.slug)).capitalize())
    except NameError:
        return HttpResponseRedirect(reverse_lazy('view-task', kwargs={'slug': slug}))

    if TaskResult.objects.filter(user=user, task__slug=slug).exists():
        return HttpResponseRedirect(reverse_lazy('update-task', kwargs={'slug': slug}))

    return HttpResponseRedirect(reverse_lazy('create-task', kwargs={'slug': slug}))
Esempio n. 3
0
 def get_form_class(self):
     task = TaskInfo.objects.get(slug=self.kwargs['slug'])
     return eval('Task%sResultForm' % slugify(unicode(task.slug)).capitalize())
Esempio n. 4
0
 def get_object(self, queryset=None):
     task = TaskInfo.objects.get(slug=self.kwargs['slug'])
     return eval('Task%sResult()' % slugify(unicode(task.slug)).capitalize())
Esempio n. 5
0
def get_task_form(slug, user):
    task_class = eval('Task%sResult' % slugify(unicode(slug)).capitalize())
    task_result = task_class.objects.order_by('-created').filter(task__slug=slug, user=user)[0]
    task_form_class = eval('Task%sResultForm' % slugify(unicode(slug)).capitalize())
    return task_form_class(instance=task_result)