Exemple #1
0
    def post(self, request):
        form = CreateAuthorForm.create_from_request(request)

        if not form.is_valid():
            raise ValidationException(request, form)

        if not has_object_permission('check_catalog_write', request.user,
                                     form.cleaned_data['catalog_id']):
            raise ProblemDetailException(request,
                                         _("Insufficient permissions"),
                                         status=HTTPStatus.FORBIDDEN)

        if Author.objects.filter(
                catalog=form.cleaned_data['catalog_id'],
                name=form.cleaned_data['name'],
                surname=form.cleaned_data['surname']).exists():
            raise ProblemDetailException(
                request,
                _("Author already exists in the catalog"),
                status=HTTPStatus.CONFLICT)

        author = Author()
        form.populate(author)
        author.save()

        return SingleResponse(request,
                              author,
                              serializer=AuthorSerializer.Detailed,
                              status=HTTPStatus.CREATED)
Exemple #2
0
def parse_task(taskxml, recipe):
    testname = taskxml.getAttribute("name")
    test, status = Test.objects.get_or_create(
        name=testname, defaults={"owner": Author.parseAuthor("")})

    uid = taskxml.getAttribute("id")
    status_str = taskxml.getAttribute("status")
    result = taskxml.getAttribute("result")
    task_alias = None
    for params in taskxml.getElementsByTagName("params"):
        for param in params.getElementsByTagName("param"):
            if param.getAttribute("name") == "TASK_ALIAS":
                task_alias = param.getAttribute("value")

    task, status = Task.objects.get_or_create(uid="T:%s" % uid,
                                              defaults={
                                                  "recipe": recipe,
                                                  "test": test,
                                                  "alias": task_alias,
                                              })
    task.set_result(result)
    task.set_status(status_str)

    if task.is_completed():
        duration = taskxml.getAttribute("duration")
        if duration:
            task.duration = float(strToSec(duration))
    task.save()
Exemple #3
0
def parse_task(taskxml, recipe):
    testname = taskxml.getAttribute("name")
    test, status = Test.objects.get_or_create(name=testname, defaults={
        "owner": Author.parseAuthor("")
    })

    uid = taskxml.getAttribute("id")
    status_str = taskxml.getAttribute("status")
    result = taskxml.getAttribute("result")
    task_alias = None
    for params in taskxml.getElementsByTagName("params"):
        for param in params.getElementsByTagName("param"):
            if param.getAttribute("name") == "TASK_ALIAS":
                task_alias = param.getAttribute("value")

    task, status = Task.objects.get_or_create(
        uid=uid,
        defaults={
            "recipe": recipe,
            "test": test,
            "alias": task_alias,
        }
    )
    task.set_result(result)
    task.set_status(status_str)

    if task.is_completed():
        task.duration = float(strToSec(taskxml.getAttribute("duration")))
    task.save()
Exemple #4
0
    def get_context_data(self, **kwargs):
        context = super(self.__class__, self).get_context_data(**kwargs)
        context['detailPanelHidden'] = self.request.COOKIES.get('detailHidden')
        context['detailPanelHeight'] = int(
            self.request.COOKIES.get('detailHeight', 0))
        context['detailActions'] = [
            Comment.ENUM_ACTION_WAIVED, Comment.ENUM_ACTION_RETURN,
            Comment.ENUM_ACTION_RESCHEDULE
        ]
        context['waiveClass'] = Comment
        context['GITWEB_URL'] = settings.GITWEB_URL

        # Get all tags
        context["actualtag"] = self.filters.get("tag")
        context['tags'] = Tag.objects.all()

        # Get scheduled jobs
        filters, jobstag = {}, {}

        if self.filters.get('search'):
            filters.update({
                "job__template__whiteboard__icontains":
                self.filters.get('search'),
            })

        if self.filters.get("tag"):
            jobstag = JobTemplate.objects.filter(
                tags__slug=self.filters.get("tag"))
            filters.update({
                "job__template__in": jobstag,
            })

        # Get all data from database for jobs ###
        joblist = JobListObject(**filters)
        if self.request.GET.get("back"):
            joblist.set_history(self.request.GET.get("back"))
        context['plans'] = joblist.get_data()

        try:
            context['progress'] = CheckProgress.objects.order_by(
                "-datestart")[0]
        except IndexError:
            context['progress'] = None
        # Search box
        context['forms'] = self.forms.get('search', FilterForm())
        # Waive Form
        author = Author.FromUser(self.request.user)
        if author:
            waiveform = WaiverForm(initial={"username": author.name})
        else:
            waiveform = WaiverForm()
        context['waiveForm'] = self.forms.get('waiveForm', waiveform)

        # get all tags

        context["events"] = Event.objects.filter(is_enabled=True,
                                                 datestart__lt=timezone.now(),
                                                 dateend__gt=timezone.now())
        return context
Exemple #5
0
def parse_task(taskxml, recipe):

    #   stat = dict()
    #    for result in taskxml.childNodes:
    #        for it in result.childNodes:
    #            res = it.getAttribute("result")
    #            if not res: continue
    #            if stat.has_key(res):
    #                stat[res] += 1
    #            else:
    #                stat[res] = 1

    testname = taskxml.getAttribute("name")
    test, status = Test.objects.get_or_create(name=testname, defaults={
        "owner": Author.parseAuthor("")
    })

    uid = taskxml.getAttribute("id")
    status_str = taskxml.getAttribute("status")
    result = taskxml.getAttribute("result")

    task_alias = None
    for params in taskxml.getElementsByTagName("params"):
        for param in params.getElementsByTagName("param"):
            if param.getAttribute("name") == "TASK_ALIAS":
                task_alias = param.getAttribute("value")

    # Download data from journal.xml
    # task_full_xml = None
    # response = None
    # try:
    #  response = urllib2.urlopen(settings.BEAKER_TASK_LOG+"%s+/%s/journal.xml")
    #  task_full_xml = parse(response)
    # except:
    #  pass
    # finally:
    #  if response:
    #    response.close()
    #
    # if task_full_xml:
    #   task_full_xml.getElementsByTagName('starttime')[0].childNodes[0].nodeValue.strip()

    task, status = Task.objects.get_or_create(
        uid=uid,
        defaults={
            "recipe": recipe,
            "test": test,
            "alias": task_alias,
        }
    )
    task.set_result(result)
    task.set_status(status_str)

    if task.is_completed():
        task.duration = float(strToSec(taskxml.getAttribute("duration")))
    task.save()
Exemple #6
0
    def render_to_response(self, context, **response_kwargs):
        """???"""
        context['forms'] = self.forms.get('search', FilterForm())
        author = Author.FromUser(self.request.user)
        if author:
            waiveform = WaiverForm(initial={"username": author.name})
        else:
            waiveform = WaiverForm()
        context['waiveForm'] = self.forms.get('waiveForm', waiveform)

        return super(self.__class__,
                     self).render_to_response(context, **response_kwargs)