Example #1
0
class ArtifactDeleteView(SuccessMessageMixin, DeleteView):
    """
    #class:US009
    """
    model = ArtifactService.get_model()
    template_name = 'artifact/delete.html'
    fields = ('name', 'type', 'title', 'description', 'reference', 'requeriment','sprint','userstory','file')

    def get_success_url(self):
        requeriment_id = False
        sprint_id = False
        userstory_id = False
        if 'requeriment_id' in self.kwargs:
            requeriment_id = self.kwargs['requeriment_id']
        if 'sprint_id' in self.kwargs:
            sprint_id = self.kwargs['sprint_id']
        if 'userstory' in self.kwargs:
            userstory_id = self.kwargs['userstory']
        return activity_sucess_url(requeriment_id, sprint_id, userstory_id)

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

    def get_context_data(self, **kwargs):
        context = super(ArtifactDeleteView, self).get_context_data()
        return context
Example #2
0
class ActivityUpdateFormView(UpdateFormView):
    """
    #class:US015
    """
    page_title = _('Activity')
    model = ArtifactService.get_model()
    success_message = _('Activity was updated successfully')
    breadcrumbs = (
        {'link': reverse_lazy('main:home'), 'class': '', 'name': _('Home')},
        {'link': reverse_lazy('main:sprint'), 'class': '', 'name': _('Sprint')},
        {'link': '#', 'class': '', 'name': _('Add')},
    )
    form_class = None
    tabs = None

    def get_form_class(self):
        if 'userstory' in self.kwargs:
            self.tabs = (
                {"title": _("Activity"), "id": "activity", "class": "active",
                 "fields": ('user', 'title', 'description', 'type', 'userstory',)},
                {"title": _("Time"), "id": "time",
                 "fields": ('create_date', 'estimated_time', 'closed_date', 'spent_time')},
                {"title": _("Points"), "id": "points",
                 "fields": ('estimated_storypoints', 'realized_storypoints')},
                {"title": "BV", "id": "bv",
                 "fields": ('estimated_businnesvalue', 'realized_businnesvalue')},
            )
            form = ActivityUserStoryForm
        elif 'sprint_id' in self.kwargs and 'requeriment_id' not in self.kwargs:
            self.tabs = (
                {"title": _("Activity"), "id": "activity", "class": "active",
                 "fields": ('user', 'title', 'description', 'type', 'sprint',)},
                {"title": _("Time"), "id": "time",
                 "fields": ('create_date', 'estimated_time', 'closed_date', 'spent_time')},
                {"title": _("Points"), "id": "points",
                 "fields": ('estimated_storypoints', 'realized_storypoints')},
                {"title": "BV", "id": "bv",
                 "fields": ('estimated_businnesvalue', 'realized_businnesvalue')},
            )
            form =  ActivitySprintForm
        elif 'requeriment_id' in self.kwargs:
            self.tabs = (
                {"title": _("Activity"), "id": "activity", "class": "active",
                 "fields": ('user', 'title', 'description', 'type', 'requeriment',)},
                {"title": _("Time"), "id": "time",
                 "fields": ('create_date', 'estimated_time', 'closed_date', 'spent_time')},
                {"title": _("Points"), "id": "points",
                 "fields": ('estimated_storypoints', 'realized_storypoints')},
                {"title": "BV", "id": "bv",
                 "fields": ('estimated_businnesvalue', 'realized_businnesvalue')},
            )
            form = ActivityRequerimentForm
        else:
            self.tabs = (
                {"title": _("Activity"), "id": "activity", "class": "active",
                 "fields": ('user', 'title', 'description', 'type', )},
                {"title": _("Time"), "id": "time",
                 "fields": ('create_date', 'estimated_time', 'closed_date', 'spent_time')},
                {"title": _("Points"), "id": "points",
                 "fields": ('estimated_storypoints', 'realized_storypoints')},
                {"title": "BV", "id": "bv",
                 "fields": ('estimated_businnesvalue', 'realized_businnesvalue')},
            )
            form = ActivityProjectForm
        return form

    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

    def get_success_url(self):
        if 'back' in self.kwargs:
            return reverse_lazy('main:artifact-list-activity')
        requeriment_id = False
        sprint_id = False
        userstory_id = False
        if 'requeriment_id' in self.kwargs:
            requeriment_id = self.kwargs['requeriment_id']
        if 'sprint_id' in self.kwargs:
            sprint_id = self.kwargs['sprint_id']
        if 'userstory' in self.kwargs:
            userstory_id = self.kwargs['userstory']
        return activity_sucess_url(requeriment_id, sprint_id, userstory_id)

    @method_decorator(require_project())
    def dispatch(self, request, *args, **kwargs):
        return super(ActivityUpdateFormView, 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(ActivityUpdateFormView, self).form_valid(form)

    def get_context_data(self, **kwargs):
        context = super(ActivityUpdateFormView, self).get_context_data(**kwargs)
        userstory_id = False
        sprint_id = False
        requeriment_id = False
        if 'userstory' in self.kwargs: #userstory
            userstory_id = self.kwargs['userstory']
        if 'sprint_id' in self.kwargs:
            sprint_id =  self.kwargs['sprint_id']
        if 'requeriment_id' in self.kwargs:
            requeriment_id = self.kwargs['requeriment_id']
        context['breadcrumbs'] = userstories_breadcrumbs(self.request.session['project_id'], requeriment_id, sprint_id, userstory_id, _('Update Activity'))
        return context