Exemple #1
0
def stream_history(request, name):
    draft = get_object_or_404(InternetDraft, filename=name)
    streamed = get_streamed_draft(draft)
    stream = get_stream_from_draft(draft)
    workflow = get_workflow_for_draft(draft)
    tags = []
    if settings.USE_DB_REDESIGN_PROXY_CLASSES:
        used = list(draft.tags.all())
        tags = DocTagName.objects.filter(slug__in=get_tags_for_stream_id(draft.stream_id))
        for t in tags:
            t.setted = t.slug in used
    else:
        if workflow:
            tags_setted = [i.annotation_tag.pk for i in get_annotation_tags_for_draft(draft)]
            for tag in workflow.get_tags():
                tag.setted = tag.pk in tags_setted
                tags.append(tag)
    state = get_state_for_draft(draft)
    history = get_workflow_history_for_draft(draft)
    show_more = False
    if len(history) > REDUCED_HISTORY_LEN:
        show_more = True

    return render_to_response('ietfworkflows/stream_history.html',
                              {'stream': stream,
                               'streamed': streamed,
                               'draft': draft,
                               'tags': tags,
                               'state': state,
                               'workflow': workflow,
                               'show_more': show_more,
                               'history': history[:REDUCED_HISTORY_LEN],
                              },
                              context_instance=RequestContext(request))
Exemple #2
0
def get_full_info_for_draft(draft):
    return dict(
        streamed=get_streamed_draft(draft),
        stream=get_stream_from_draft(draft),
        workflow=get_workflow_for_draft(draft),
        tags=[i.annotation_tag for i in get_annotation_tags_for_draft(draft)],
        state=get_state_for_draft(draft),
        shepherd=draft.shepherd if draft.shepherd_id else None,
    )
Exemple #3
0
def get_workflow_for_draft(draft):
    if settings.USE_DB_REDESIGN_PROXY_CLASSES:
        return True if get_streamed_draft(draft) else None

    workflow = get_workflow_for_object(draft)
    try:
        workflow = workflow and workflow.wgworkflow
    except WGWorkflow.DoesNotExist:
        workflow = None
    if not workflow:
        streamed_draft = get_streamed_draft(draft)
        if not streamed_draft or not streamed_draft.stream:
            return None
        stream = streamed_draft.stream
        if stream.document_group_attribute:
            group = streamed_draft.get_group()
            if not group:
                return None
            else:
                workflow = get_workflow_for_wg(group, streamed_draft.stream.workflow)
        else:
            workflow = stream.workflow
        set_workflow_for_object(draft, workflow)
    return workflow
Exemple #4
0
def is_authorized_in_draft_stream(user, draft):
    if is_secretariat(user):
        return True
    person = get_person_for_user(user)
    if not person:
        return False
    streamed = get_streamed_draft(draft)
    if not streamed or not streamed.stream:
        return False
    # Check if the person is chair of the stream
    if is_chair_of_stream(user, streamed.stream):
        return True
    # Check if the person is delegate of the stream
    if is_delegate_of_stream(user, streamed.stream):
        return True
    # Check if the person is chair of the related group
    chairs = streamed.stream.get_chairs_for_document(draft)
    if chairs and person in [i.person for i in chairs]:
        return True
    # Check if the person is authorized by a delegate system
    delegates = streamed.stream.get_delegates_for_document(draft)
    return bool(person in delegates)
Exemple #5
0
def is_authorized_in_draft_stream(user, draft):
    if is_secretariat(user):
        return True
    person = get_person_for_user(user)
    if not person:
        return False
    streamed = get_streamed_draft(draft)
    if not streamed or not streamed.stream:
        return False
    # Check if the person is chair of the stream
    if is_chair_of_stream(user, streamed.stream):
        return True
    # Check if the person is delegate of the stream
    if is_delegate_of_stream(user, streamed.stream):
        return True
    # Check if the person is chair of the related group
    chairs = streamed.stream.get_chairs_for_document(draft)
    if chairs and person in [i.person for i in chairs]:
        return True
    # Check if the person is authorized by a delegate system
    delegates = streamed.stream.get_delegates_for_document(draft)
    return bool(person in delegates)
Exemple #6
0
def stream_history(request, name):
    draft = get_object_or_404(InternetDraft, filename=name)
    streamed = get_streamed_draft(draft)
    stream = get_stream_from_draft(draft)
    workflow = get_workflow_for_draft(draft)
    tags = []
    if settings.USE_DB_REDESIGN_PROXY_CLASSES:
        used = list(draft.tags.all())
        tags = DocTagName.objects.filter(
            slug__in=get_tags_for_stream_id(draft.stream_id))
        for t in tags:
            t.setted = t.slug in used
    else:
        if workflow:
            tags_setted = [
                i.annotation_tag.pk
                for i in get_annotation_tags_for_draft(draft)
            ]
            for tag in workflow.get_tags():
                tag.setted = tag.pk in tags_setted
                tags.append(tag)
    state = get_state_for_draft(draft)
    history = get_workflow_history_for_draft(draft)
    show_more = False
    if len(history) > REDUCED_HISTORY_LEN:
        show_more = True

    return render_to_response('ietfworkflows/stream_history.html', {
        'stream': stream,
        'streamed': streamed,
        'draft': draft,
        'tags': tags,
        'state': state,
        'workflow': workflow,
        'show_more': show_more,
        'history': history[:REDUCED_HISTORY_LEN],
    },
                              context_instance=RequestContext(request))
Exemple #7
0
    def save(self):
        comment = self.cleaned_data.get('comment').strip()
        weeks = self.cleaned_data.get('weeks')
        group = IETFWG.objects.get(pk=self.cleaned_data.get('group'))
        estimated_date = None
        if weeks:
            now = datetime.date.today()
            estimated_date = now + datetime.timedelta(weeks=weeks)
        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            # do changes on real Document object instead of proxy to avoid trouble
            doc = Document.objects.get(pk=self.draft.pk)
            save_document_in_history(doc)

            doc.time = datetime.datetime.now()

            if group.type.slug == "rg":
                new_stream = StreamName.objects.get(slug="irtf")
            else:
                new_stream = StreamName.objects.get(slug="ietf")

            if doc.stream != new_stream:
                e = DocEvent(type="changed_stream")
                e.time = doc.time
                e.by = self.user.get_profile()
                e.doc = doc
                e.desc = u"Changed to <b>%s</b>" % new_stream.name
                if doc.stream:
                    e.desc += u" from %s" % doc.stream.name
                e.save()
                doc.stream = new_stream

            if doc.group.pk != group.pk:
                e = DocEvent(type="changed_group")
                e.time = doc.time
                e.by = self.user.get_profile()
                e.doc = doc
                e.desc = u"Changed group to <b>%s (%s)</b>" % (
                    group.name, group.acronym.upper())
                if doc.group.type_id != "individ":
                    e.desc += " from %s (%s)" % (doc.group.name,
                                                 doc.group.acronym)
                e.save()
                doc.group_id = group.pk

            doc.save()
            self.draft = InternetDraft.objects.get(
                pk=doc.pk)  # make sure proxy object is updated
        else:
            workflow = get_workflow_for_wg(wg)
            set_workflow_for_object(self.draft, workflow)
            stream = get_stream_by_name(IETF_STREAM)
            streamed = get_streamed_draft(self.draft)
            if not streamed:
                set_stream_for_draft(self.draft, stream)
                streamed = get_streamed_draft(self.draft)
            streamed.stream = stream
            streamed.group = wg
            streamed.save()

        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            from ietf.doc.models import State
            if self.draft.stream_id == "irtf":
                to_state = State.objects.get(used=True,
                                             slug="active",
                                             type="draft-stream-irtf")
            else:
                to_state = State.objects.get(used=True,
                                             slug="c-adopt",
                                             type="draft-stream-%s" %
                                             self.draft.stream_id)
        else:
            to_state = get_state_by_name(CALL_FOR_ADOPTION)
        update_state(self.request,
                     self.draft,
                     comment=comment,
                     person=self.person,
                     to_state=to_state,
                     estimated_date=estimated_date)

        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            if comment:
                e = DocEvent(type="added_comment")
                e.time = self.draft.time
                e.by = self.person
                e.doc_id = self.draft.pk
                e.desc = comment
                e.save()
Exemple #8
0
    def save(self):
        comment = self.cleaned_data.get('comment').strip()
        weeks = self.cleaned_data.get('weeks')
        group = IETFWG.objects.get(pk=self.cleaned_data.get('group'))
        estimated_date = None
        if weeks:
            now = datetime.date.today()
            estimated_date = now + datetime.timedelta(weeks=weeks)
        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            # do changes on real Document object instead of proxy to avoid trouble
            doc = Document.objects.get(pk=self.draft.pk)
            save_document_in_history(doc)

            doc.time = datetime.datetime.now()

            if group.type.slug == "rg":
                new_stream = StreamName.objects.get(slug="irtf")                
            else:
                new_stream = StreamName.objects.get(slug="ietf")                

            if doc.stream != new_stream:
                e = DocEvent(type="changed_stream")
                e.time = doc.time
                e.by = self.user.get_profile()
                e.doc = doc
                e.desc = u"Changed to <b>%s</b>" % new_stream.name
                if doc.stream:
                    e.desc += u" from %s" % doc.stream.name
                e.save()
                doc.stream = new_stream

            if doc.group.pk != group.pk:
                e = DocEvent(type="changed_group")
                e.time = doc.time
                e.by = self.user.get_profile()
                e.doc = doc
                e.desc = u"Changed group to <b>%s (%s)</b>" % (group.name, group.acronym.upper())
                if doc.group.type_id != "individ":
                    e.desc += " from %s (%s)" % (doc.group.name, doc.group.acronym)
                e.save()
                doc.group_id = group.pk

            doc.save()
            self.draft = InternetDraft.objects.get(pk=doc.pk) # make sure proxy object is updated
        else:
            workflow = get_workflow_for_wg(wg)
            set_workflow_for_object(self.draft, workflow)
            stream = get_stream_by_name(IETF_STREAM)
            streamed = get_streamed_draft(self.draft)
            if not streamed:
                set_stream_for_draft(self.draft, stream)
                streamed = get_streamed_draft(self.draft)
            streamed.stream = stream
            streamed.group = wg
            streamed.save()

        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            from ietf.doc.models import State
            if self.draft.stream_id == "irtf":
                to_state = State.objects.get(used=True, slug="active", type="draft-stream-irtf")
            else:
                to_state = State.objects.get(used=True, slug="c-adopt", type="draft-stream-%s" % self.draft.stream_id)
        else:
            to_state = get_state_by_name(CALL_FOR_ADOPTION)
        update_state(self.request, self.draft,
                     comment=comment,
                     person=self.person,
                     to_state=to_state,
                     estimated_date=estimated_date)

        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            if comment:
                e = DocEvent(type="added_comment")
                e.time = self.draft.time
                e.by = self.person
                e.doc_id = self.draft.pk
                e.desc = comment
                e.save()