Exemplo n.º 1
0
    def get_context_data(self, **kwargs):
        context = super(ArtifactDocumentForm, self).get_context_data(**kwargs)
        project = ProjectService.get_project(self.request.session['project_id'])
        context['project']=project
        context['local_repository']=settings.REPOSITORY_DIR
        if self.request.is_secure():
            url = 'https://'+get_current_site(self.request).domain
        else:
            url = 'http://'+get_current_site(self.request).domain

        if 'userstory' in self.kwargs: #userstory
            userstory = UserStoryService.get_userstory(self.request.session['project_id'], self.kwargs['userstory'])
            context['artifacttype'] = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 3, 0)
            context['artifact'] = UserStoryService.get_artifacts(self.request.session['project_id'], userstory)
            context['page_title'] = _('UserStory Artifacts')
            context['url'] = url+'/userstory/'+str(userstory.id)+'/detail/artifact/'
            context['breadcrumbs'] = userstories_breadcrumbs(
                self.request.session.get('project_id'),
                self.kwargs.get('requeriment_id'),
                self.kwargs.get('sprint_id'),
                self.kwargs.get('userstory'),
                'Artifacts'
            )
        elif 'sprint_id' in self.kwargs:
            sprint = SprintService.get_sprint(self.request.session['project_id'], self.kwargs['sprint_id'])
            context['artifacttype'] = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 2, 0)
            context['artifact'] = SprintService.get_artifacts(self.request.session['project_id'], sprint)
            context['page_title'] = _('Sprint Artifacts')
            context['breadcrumbs'] = (
               {'link': reverse_lazy('main:home'), 'class': '', 'name': _('Home')},
               {'link': reverse_lazy('main:sprint'), 'class': '', 'name': _('Sprint')},
               {'link': reverse_lazy('main:sprint-details',kwargs={'sprint_id':sprint.id}), 'class': '', 'name': sprint},
               {'link': '#', 'class': '', 'name': _('Artifacts')},
            )
        elif 'requeriment_id' in self.kwargs:
            requeriment = RequerimentService.get_requeriment(self.request.session['project_id'], self.kwargs['requeriment_id'])
            context['artifacttype'] = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 1, 0)
            context['artifact'] = RequerimentService.get_artifacts(self.request.session['project_id'], requeriment)
            context['page_title'] = _('Requeriment Artifacts')
            context['breadcrumbs'] = (
                {'link': reverse_lazy('main:home'), 'class': '', 'name': _('Home')},
                {'link': reverse_lazy('main:requeriment'), 'class': '', 'name': _('Requeriment')},
                {'link': reverse_lazy('main:requeriment-details', kwargs={'pk': requeriment.id}), 'class': '',
                 'name': requeriment.code},
                {'link': '#', 'class': '', 'name': _('Artifacts')},
            )
        else:
            context['artifact'] = ProjectService.get_artifacts(self.request.session['project_id'])
            context['artifacttype'] = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 0, 0)
            context['page_title'] = _('Project Artifacts')
        return context
Exemplo n.º 2
0
 def get_form(self, *args, **kwargs):
     form = super(ActivityUpdateFormView, self).get_form(*args, **kwargs)
     if 'userstory' in self.kwargs:
         form.fields['type'].queryset = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 3,
                                                                              2)
     elif 'sprint_id' in self.kwargs and 'requeriment_id' not in self.kwargs:
         form.fields['type'].queryset = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 2,
                                                                              2)
     elif 'requeriment_id' in self.kwargs:
         form.fields['type'].queryset = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 1,
                                                                              2)
     else:
         form.fields['type'].queryset = ArtifactTypeService.get_artifactstype(self.request.session['project_id'], 0,
                                                                              2)
     if self.request.user.is_superuser:
         form.fields['user'].queryset = ProjectService.get_users_from_project(self.request.session['project_id'])
     return form
Exemplo n.º 3
0
class ArtifactTypeDeleteView(SuccessMessageMixin, DeleteView):
    """
    #class:US008
    """
    model = ArtifactTypeService.get_artifacttype_model()
    template_name = 'artifacttype/delete.html'
    list_display = ('name', 'level', 'type', 'trace_code')

    def get_success_url(self):
        return reverse('main:artifacttype')

    @method_decorator(require_project())
    def dispatch(self, request, *args, **kwargs):
        return super(ArtifactTypeDeleteView,
                     self).dispatch(request, *args, **kwargs)
Exemplo n.º 4
0
class ArtifactTypeUpdateFormView(UpdateFormView):
    """
    #class:US008
    """
    page_title = _('Artifact type')
    model = ArtifactTypeService.get_artifacttype_model()
    form_class = ArtifactTypeForm

    success_message = _('Artifacty Type was updated successfully')
    tabs = ({
        "title": _('Artifact type'),
        "id": "artifacttype",
        "class": "active",
        "fields": ('name', 'level', 'type', 'trace_code')
    }, )
    breadcrumbs = (
        {
            'link': reverse_lazy('main:home'),
            'class': '',
            'name': _('Home')
        },
        {
            'link': reverse_lazy('main:artifacttype'),
            'class': '',
            'name': _('Artifact Type')
        },
    )

    def get_success_url(self):
        return reverse('main:artifacttype')

    @method_decorator(require_project())
    def dispatch(self, request, *args, **kwargs):
        return super(ArtifactTypeUpdateFormView,
                     self).dispatch(request, *args, **kwargs)

    def form_valid(self, form):
        project = ProjectService.get_project(
            self.request.session['project_id'])
        #form.instance.changed_by = self.request.user
        form.instance.project = project
        return super(ArtifactTypeUpdateFormView, self).form_valid(form)
Exemplo n.º 5
0
class ArtifactTypeView(ModelListProjectFilter):
    """
    #class:US008
    """
    model = ArtifactTypeService.get_artifacttype_model()
    paginate_by = 20
    list_display = ('name', 'level', 'type', 'trace_code')
    top_bar = 'artifacttype/top_bar.html'
    page_title = _('Artifact type')
    breadcrumbs = (
        {
            'link': reverse_lazy('main:home'),
            'class': '',
            'name': _('Home')
        },
        {
            'link': reverse_lazy('main:artifacttype'),
            'class': '',
            'name': _('Artifact type')
        },
    )