示例#1
0
def default_review_text(group, charter, by):
    now = datetime.datetime.now()
    addrs=gather_address_lists('charter_external_review',group=group).as_strings(compact=False)

    e1 = WriteupDocEvent(doc=charter, by=by)
    e1.by = by
    e1.type = "changed_review_announcement"
    e1.desc = "%s review text was changed" % group.type.name
    e1.text = render_to_string("doc/charter/review_text.txt",
                              dict(group=group,
                                    charter_url=settings.IDTRACKER_BASE_URL + charter.get_absolute_url(),
                                    charter_text=read_charter_text(charter),
                                    chairs=group.role_set.filter(name="chair"),
                                    secr=group.role_set.filter(name="secr"),
                                    techadv=group.role_set.filter(name="techadv"),
                                    milestones=group.groupmilestone_set.filter(state="charter"),
                                    review_date=(datetime.date.today() + datetime.timedelta(weeks=1)).isoformat(),
                                    review_type="new" if group.state_id == "proposed" else "recharter",
                                    to=addrs.to,
                                    cc=addrs.cc,
                                   )
                              )
    e1.time = now
    e1.save()
    
    e2 = WriteupDocEvent(doc=charter, by=by)
    e2.by = by
    e2.type = "changed_new_work_text"
    e2.desc = "%s review text was changed" % group.type.name
    e2.text = derive_new_work_text(e1.text,group)
    e2.time = now
    e2.save()

    return (e1,e2)
示例#2
0
def ballot_rfceditornote(request, name):
    """Editing of RFC Editor Note"""
    doc = get_object_or_404(Document, docalias__name=name)

    if not is_authorized_in_doc_stream(request.user, doc):
        return HttpResponseForbidden(
            "You do not have the necessary permissions to change the RFC Editor Note for this document"
        )

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent,
                                type="changed_rfc_editor_note_text")
    if not existing or (existing.text == ""):
        existing = generate_ballot_rfceditornote(request, doc)

    form = BallotRfcEditorNoteForm(auto_id=False,
                                   initial=dict(rfc_editor_note=existing.text))

    if request.method == 'POST' and "save_ballot_rfceditornote" in request.POST:
        form = BallotRfcEditorNoteForm(request.POST)
        if form.is_valid():
            t = form.cleaned_data["rfc_editor_note"]
            if t != existing.text:
                e = WriteupDocEvent(doc=doc, rev=doc.rev, by=login)
                e.by = login
                e.type = "changed_rfc_editor_note_text"
                e.desc = "RFC Editor Note was changed"
                e.text = t.rstrip()
                e.save()

    if request.method == 'POST' and "clear_ballot_rfceditornote" in request.POST:
        e = WriteupDocEvent(doc=doc, rev=doc.rev, by=login)
        e.by = login
        e.type = "changed_rfc_editor_note_text"
        e.desc = "RFC Editor Note was cleared"
        e.text = ""
        e.save()

        # make sure form shows a blank RFC Editor Note
        form = BallotRfcEditorNoteForm(initial=dict(rfc_editor_note=" "))

    return render(
        request, 'doc/ballot/rfceditornote.html',
        dict(
            doc=doc,
            back_url=doc.get_absolute_url(),
            ballot_rfceditornote_form=form,
        ))
示例#3
0
文件: mails.py 项目: ekr/ietfdb
def generate_last_call_announcement(request, doc):
    expiration_date = datetime.date.today() + datetime.timedelta(days=14)
    if doc.group.type_id in ("individ", "area"):
        group = "an individual submitter"
        expiration_date += datetime.timedelta(days=14)
    else:
        group = "the %s %s (%s)" % (doc.group.name, doc.group.type.name,
                                    doc.group.acronym)

    doc.filled_title = textwrap.fill(doc.title,
                                     width=70,
                                     subsequent_indent=" " * 3)

    iprs = iprs_from_docs(
        related_docs(DocAlias.objects.get(name=doc.canonical_name())))
    if iprs:
        ipr_links = [
            urlreverse("ietf.ipr.views.show", kwargs=dict(id=i.id))
            for i in iprs
        ]
        ipr_links = [
            settings.IDTRACKER_BASE_URL +
            url if not url.startswith("http") else url for url in ipr_links
        ]
    else:
        ipr_links = None

    downrefs = [
        rel for rel in doc.relateddocument_set.all()
        if rel.is_downref() and not rel.is_approved_downref()
    ]

    addrs = gather_address_lists('last_call_issued', doc=doc).as_strings()
    mail = render_to_string(
        "doc/mail/last_call_announcement.txt",
        dict(
            doc=doc,
            doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url() +
            "ballot/",
            expiration_date=expiration_date.strftime(
                "%Y-%m-%d"),  #.strftime("%B %-d, %Y"),
            to=addrs.to,
            cc=addrs.cc,
            group=group,
            docs=[doc],
            urls=[settings.IDTRACKER_BASE_URL + doc.get_absolute_url()],
            ipr_links=ipr_links,
            downrefs=downrefs,
        ))

    e = WriteupDocEvent()
    e.type = "changed_last_call_text"
    e.by = request.user.person
    e.doc = doc
    e.rev = doc.rev
    e.desc = u"Last call announcement was generated"
    e.text = unicode(mail)

    # caller is responsible for saving, if necessary
    return e
示例#4
0
def generate_last_call_text(request, doc):

    # requester should be set based on doc.group once the group for a status change can be set to something other than the IESG
    # and when groups are set, vary the expiration time accordingly

    requester = "an individual participant"
    expiration_date = datetime.date.today() + datetime.timedelta(days=28)
    cc = []
    
    new_text = render_to_string("doc/status_change/last_call_announcement.txt",
                                dict(doc=doc,
                                     settings=settings,
                                     requester=requester,
                                     expiration_date=expiration_date.strftime("%Y-%m-%d"),
                                     changes=['%s from %s to %s'%(rel.target.name.upper(),rel.target.document.std_level.name,newstatus(rel)) for rel in doc.relateddocument_set.filter(relationship__slug__in=RELATION_SLUGS)],
                                     urls=[rel.target.document.get_absolute_url() for rel in doc.relateddocument_set.filter(relationship__slug__in=RELATION_SLUGS)],
                                     cc=cc
                                    )
                               )

    e = WriteupDocEvent()
    e.type = 'changed_last_call_text'
    e.by = request.user.get_profile()
    e.doc = doc
    e.desc = 'Last call announcement was generated'
    e.text = unicode(new_text)
    e.save()

    return e 
示例#5
0
def announcement_text(request, name, ann):
    """Editing of announcement text"""
    charter = get_object_or_404(Document, type="charter", name=name)
    group = charter.group

    login = request.user.person

    if ann in ("action", "review"):
        existing = charter.latest_event(WriteupDocEvent, type="changed_%s_announcement" % ann)
    if not existing:
        if ann == "action":
            existing = default_action_text(group, charter, login)
        elif ann == "review":
            existing = default_review_text(group, charter, login)

    if not existing:
        raise Http404

    form = AnnouncementTextForm(initial=dict(announcement_text=existing.text))

    if request.method == 'POST':
        form = AnnouncementTextForm(request.POST)
        if "save_text" in request.POST and form.is_valid():
            t = form.cleaned_data['announcement_text']
            if t != existing.text:
                e = WriteupDocEvent(doc=charter, by=login)
                e.by = login
                e.type = "changed_%s_announcement" % ann
                e.desc = "%s %s text was changed" % (group.type.name, ann)
                e.text = t
                e.save()
                
                charter.time = e.time
                charter.save()

            if request.GET.get("next", "") == "approve":
                return redirect('charter_approve', name=charter.canonical_name())

            return redirect('doc_writeup', name=charter.canonical_name())

        if "regenerate_text" in request.POST:
            if ann == "action":
                e = default_action_text(group, charter, login)
            elif ann == "review":
                e = default_review_text(group, charter, login)
            # make sure form has the updated text
            form = AnnouncementTextForm(initial=dict(announcement_text=e.text))

        if "send_text" in request.POST and form.is_valid():
            parsed_msg = send_mail_preformatted(request, form.cleaned_data['announcement_text'])
            messages.success(request, "The email To: '%s' with Subject: '%s' has been sent." % (parsed_msg["To"],parsed_msg["Subject"],))
            return redirect('doc_writeup', name=charter.name)

    return render_to_response('doc/charter/announcement_text.html',
                              dict(charter=charter,
                                   announcement=ann,
                                   back_url=urlreverse("doc_writeup", kwargs=dict(name=charter.name)),
                                   announcement_text_form=form,
                                   ),
                              context_instance=RequestContext(request))
示例#6
0
def default_action_text(group, charter, by):
    if next_approved_revision(group.charter.rev) == "01":
        action = "Formed"
    else:
        action = "Rechartered"

    addrs = gather_address_lists('ballot_approved_charter',doc=charter,group=group).as_strings(compact=False)
    e = WriteupDocEvent(doc=charter, by=by)
    e.by = by
    e.type = "changed_action_announcement"
    e.desc = "%s action text was changed" % group.type.name
    e.text = render_to_string("doc/charter/action_text.txt",
                              dict(group=group,
                                   charter_url=settings.IDTRACKER_BASE_URL + charter.get_absolute_url(),
                                   charter_text=read_charter_text(charter),
                                   chairs=group.role_set.filter(name="chair"),
                                   secr=group.role_set.filter(name="secr"),
                                   techadv=group.role_set.filter(name="techadv"),
                                   milestones=group.groupmilestone_set.filter(state="charter"),
                                   action_type=action,
                                   to=addrs.to,
                                   cc=addrs.cc,
                                   ))

    e.save()
    return e
示例#7
0
def default_action_text(group, charter, user):
    if next_approved_revision(group.charter.rev) == "01":
        action = "Formed"
    else:
        action = "Rechartered"

    e = WriteupDocEvent(doc=charter, by=user)
    e.by = user
    e.type = "changed_action_announcement"
    e.desc = "%s action text was changed" % group.type.name
    e.text = render_to_string(
        "wgcharter/action_text.txt",
        dict(
            group=group,
            charter_url=settings.IDTRACKER_BASE_URL +
            charter.get_absolute_url(),
            charter_text=read_charter_text(charter),
            chairs=group.role_set.filter(name="chair"),
            secr=group.role_set.filter(name="secr"),
            techadv=group.role_set.filter(name="techadv"),
            milestones=group.groupmilestone_set.filter(state="charter"),
            ad_email=group.ad.role_email("ad") if group.ad else None,
            action_type=action,
        ))

    e.save()
    return e
示例#8
0
def last_call(request, name):
    """Edit the Last Call Text for this status change and possibly request IETF LC"""

    status_change = get_object_or_404(Document, type="statchg", name=name)

    login = request.user.get_profile()

    last_call_event = status_change.latest_event(WriteupDocEvent, type="changed_last_call_text")
    if not last_call_event:
        last_call_event = generate_last_call_text(request, status_change)

    form = LastCallTextForm(initial=dict(last_call_text=last_call_event.text))

    if request.method == 'POST':
        if "save_last_call_text" in request.POST or "send_last_call_request" in request.POST:
            form = LastCallTextForm(request.POST)
            if form.is_valid():
                t = form.cleaned_data['last_call_text']
                if t != last_call_event.text:
                    e = WriteupDocEvent(doc=status_change, by=login)
                    e.by = login
                    e.type = "changed_last_call_text"
                    e.desc = "Last call announcement was changed"
                    e.text = t
                    e.save()

                if "send_last_call_request" in request.POST:
                    save_document_in_history(status_change)

                    old_description = status_change.friendly_state()
                    status_change.set_state(State.objects.get(type='statchg', slug='lc-req'))
                    new_description = status_change.friendly_state()

                    e = log_state_changed(request, status_change, login, new_description, old_description)

                    status_change.time = e.time
                    status_change.save()

                    request_last_call(request, status_change)

                    return render_to_response('idrfc/last_call_requested.html',
                                              dict(doc=status_change,
                                                   url = status_change.get_absolute_url(),
                                                  ),
                                              context_instance=RequestContext(request))

        if "regenerate_last_call_text" in request.POST:
            e = generate_last_call_text(request,status_change)
            form = LastCallTextForm(initial=dict(last_call_text=e.text))
            
    return render_to_response('doc/status_change/last_call.html',
                               dict(doc=status_change,
                                    back_url = status_change.get_absolute_url(),
                                    last_call_event = last_call_event,
                                    last_call_form  = form,
                                   ),
                               context_instance = RequestContext(request))
示例#9
0
def generate_ballot_writeup(request, doc):
    e = WriteupDocEvent()
    e.type = "changed_ballot_writeup_text"
    e.by = request.user.get_profile()
    e.doc = doc
    e.desc = u"Ballot writeup was generated"
    e.text = unicode(render_to_string("wgcharter/ballot_writeup.txt"))
    e.save()

    return e
示例#10
0
def generate_ballot_writeup(request, doc):
    e = WriteupDocEvent()
    e.type = "changed_ballot_writeup_text"
    e.by = request.user.person
    e.doc = doc
    e.desc = u"Ballot writeup was generated"
    e.text = unicode(render_to_string("doc/charter/ballot_writeup.txt"))
    e.save()
    
    return e
示例#11
0
def default_review_text(group, charter, by):
    now = datetime.datetime.now()
    addrs = gather_address_lists('charter_external_review',
                                 group=group).as_strings(compact=False)

    e1 = WriteupDocEvent(doc=charter, rev=charter.rev, by=by)
    e1.by = by
    e1.type = "changed_review_announcement"
    e1.desc = "%s review text was changed" % group.type.name
    e1.text = render_to_string(
        "doc/charter/review_text.txt",
        dict(
            group=group,
            group_url=settings.IDTRACKER_BASE_URL +
            urlreverse('ietf.group.views.group_home',
                       kwargs=dict(acronym=group.acronym)),
            charter_url=settings.IDTRACKER_BASE_URL +
            charter.get_absolute_url(),
            charter_text=read_charter_text(charter),
            chairs=group.role_set.filter(name="chair"),
            secr=group.role_set.filter(name="secr"),
            ads=group.role_set.filter(name='ad'),
            parent_ads=group.parent.role_set.filter(name='ad'),
            techadv=group.role_set.filter(name="techadv"),
            milestones=group.groupmilestone_set.filter(state="charter"),
            review_date=(datetime.date.today() +
                         datetime.timedelta(weeks=1)).isoformat(),
            review_type="new" if group.state_id == "proposed" else "recharter",
            to=addrs.to,
            cc=addrs.cc,
        ))
    e1.time = now

    e2 = WriteupDocEvent(doc=charter, rev=charter.rev, by=by)
    e2.by = by
    e2.type = "changed_new_work_text"
    e2.desc = "%s review text was changed" % group.type.name
    e2.text = derive_new_work_text(e1.text, group)
    e2.time = now

    # caller is responsible for saving, if necessary
    return (e1, e2)
示例#12
0
def generate_last_call_announcementREDESIGN(request, doc):

    expiration_date = date.today() + timedelta(days=14)
    cc = []
    if doc.group.type_id in ("individ", "area"):
        group = "an individual submitter"
        expiration_date += timedelta(days=14)
    else:
        group = "the %s WG (%s)" % (doc.group.name, doc.group.acronym)
        if doc.group.list_email:
            cc.append(doc.group.list_email)

    doc.filled_title = textwrap.fill(doc.title,
                                     width=70,
                                     subsequent_indent=" " * 3)

    iprs, _ = iprs_from_docs(
        related_docs(DocAlias.objects.get(name=doc.canonical_name()), []))
    if iprs:
        ipr_links = [
            urlreverse("ietf.ipr.views.show", kwargs=dict(ipr_id=i.ipr_id))
            for i in iprs
        ]
        ipr_links = [
            settings.IDTRACKER_BASE_URL +
            url if not url.startswith("http") else url for url in ipr_links
        ]
    else:
        ipr_links = None

    mail = render_to_string(
        "idrfc/last_call_announcement.txt",
        dict(
            doc=doc,
            doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url() +
            "ballot/",
            expiration_date=expiration_date.strftime(
                "%Y-%m-%d"),  #.strftime("%B %-d, %Y"),
            cc=", ".join("<%s>" % e for e in cc),
            group=group,
            docs=[doc],
            urls=[settings.IDTRACKER_BASE_URL + doc.get_absolute_url()],
            ipr_links=ipr_links,
        ))

    e = WriteupDocEvent()
    e.type = "changed_last_call_text"
    e.by = request.user.get_profile()
    e.doc = doc
    e.desc = u"Last call announcement was generated"
    e.text = unicode(mail)
    e.save()

    return e
示例#13
0
文件: mails.py 项目: ekr/ietfdb
def generate_ballot_rfceditornote(request, doc):
    e = WriteupDocEvent()
    e.type = "changed_ballot_rfceditornote_text"
    e.by = request.user.person
    e.doc = doc
    e.rev = doc.rev
    e.desc = u"RFC Editor Note for ballot was generated"
    e.text = unicode(render_to_string("doc/mail/ballot_rfceditornote.txt"))
    e.save()

    return e
示例#14
0
def generate_ballot_writeup(request, doc):
    e = WriteupDocEvent()
    e.type = "changed_ballot_writeup_text"
    e.by = request.user.person
    e.doc = doc
    e.rev = doc.rev,
    e.desc = u"Ballot writeup was generated"
    e.text = unicode(render_to_string("doc/charter/ballot_writeup.txt"))

    # caller is responsible for saving, if necessary
    return e
示例#15
0
    def save(self):
        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            e = WriteupDocEvent(type="changed_protocol_writeup")
            e.doc = self.doc
            e.by = self.person
            e.desc = e.get_type_display()
            e.text = self.cleaned_data['writeup']
            e.save()
            from ietf.wgchairs.models import ProtoWriteUpProxy
            self.doc_writeup = ProtoWriteUpProxy.objects.get(pk=e.pk)
        else:
            if not self.doc_writeup:
                self.doc_writeup = ProtoWriteUp.objects.create(
                    person=self.person,
                    draft=self.doc,
                    writeup=self.cleaned_data['writeup'])
            else:
                self.doc_writeup.writeup = self.cleaned_data['writeup']
                self.doc_writeup.save()

        if self.data.get('modify_tag', False):
            followup = self.cleaned_data.get('followup', False)
            comment = self.cleaned_data.get('comment', False)
            try:
                shepherd = self.doc.shepherd
            except PersonOrOrgInfo.DoesNotExist:
                shepherd = None
            if shepherd:
                if settings.USE_DB_REDESIGN_PROXY_CLASSES:
                    extra_notify = [shepherd.formatted_email()]
                else:
                    extra_notify = ['%s <%s>' % shepherd.email()]
            else:
                extra_notify = []
            if settings.USE_DB_REDESIGN_PROXY_CLASSES:
                tags = DocTagName.objects.filter(slug="sheph-u")
            else:
                tags = [FOLLOWUP_TAG]
            if followup:
                update_tags(self.request,
                            self.doc,
                            comment,
                            self.person,
                            set_tags=tags,
                            extra_notify=extra_notify)
            else:
                update_tags(self.request,
                            self.doc,
                            comment,
                            self.person,
                            reset_tags=tags,
                            extra_notify=extra_notify)
        return self.doc_writeup
示例#16
0
文件: mails.py 项目: algby/ietfdb
def generate_ballot_writeup(request, doc):
    e = doc.latest_event(type="iana_review")
    iana = e.desc if e else ""

    e = WriteupDocEvent()
    e.type = "changed_ballot_writeup_text"
    e.by = request.user.person
    e.doc = doc
    e.desc = u"Ballot writeup was generated"
    e.text = unicode(render_to_string("doc/mail/ballot_writeup.txt", {'iana': iana}))
    e.save()
    
    return e
示例#17
0
def ballot_approvaltext(request, name):
    """Editing of approval text"""
    doc = get_object_or_404(Document, docalias__name=name)
    if not doc.get_state("draft-iesg"):
        raise Http404

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent,
                                type="changed_ballot_approval_text")
    if not existing:
        existing = generate_approval_mail(request, doc)

    form = ApprovalTextForm(initial=dict(approval_text=existing.text))

    if request.method == 'POST':
        if "save_approval_text" in request.POST:
            form = ApprovalTextForm(request.POST)
            if form.is_valid():
                t = form.cleaned_data['approval_text']
                if t != existing.text:
                    e = WriteupDocEvent(doc=doc, rev=doc.rev, by=login)
                    e.by = login
                    e.type = "changed_ballot_approval_text"
                    e.desc = "Ballot approval text was changed"
                    e.text = t
                    e.save()
                elif existing.pk == None:
                    existing.save()

        if "regenerate_approval_text" in request.POST:
            e = generate_approval_mail(request, doc)
            e.save()

            # make sure form has the updated text
            form = ApprovalTextForm(initial=dict(approval_text=e.text))

    can_announce = doc.get_state("draft-iesg").order > 19
    need_intended_status = ""
    if not doc.intended_std_level:
        need_intended_status = doc.file_tag()

    return render(
        request, 'doc/ballot/approvaltext.html',
        dict(
            doc=doc,
            back_url=doc.get_absolute_url(),
            approval_text_form=form,
            can_announce=can_announce,
            need_intended_status=need_intended_status,
        ))
示例#18
0
def generate_ballot_writeup(request, doc):
    e = doc.latest_event(type="iana_review")
    iana = e.desc if e else ""

    e = WriteupDocEvent()
    e.type = "changed_ballot_writeup_text"
    e.by = request.user.get_profile()
    e.doc = doc
    e.desc = u"Ballot writeup was generated"
    e.text = unicode(
        render_to_string("idrfc/ballot_writeup.txt", {'iana': iana}))
    e.save()

    return e
示例#19
0
文件: mails.py 项目: algby/ietfdb
def generate_approval_mail(request, doc):
    if doc.get_state_slug("draft-iesg") in DO_NOT_PUBLISH_IESG_STATES or doc.stream_id in ('ise','irtf'):
        mail = generate_approval_mail_rfc_editor(request, doc)
    else:
        mail = generate_approval_mail_approved(request, doc)

    e = WriteupDocEvent()
    e.type = "changed_ballot_approval_text"
    e.by = request.user.person
    e.doc = doc
    e.desc = u"Ballot approval text was generated"
    e.text = unicode(mail)
    e.save()

    return e
示例#20
0
文件: mails.py 项目: ekr/ietfdb
def generate_ballot_writeup(request, doc):
    e = doc.latest_event(type="iana_review")
    iana = e.desc if e else ""

    e = WriteupDocEvent()
    e.type = "changed_ballot_writeup_text"
    e.by = request.user.person
    e.doc = doc
    e.rev = doc.rev
    e.desc = u"Ballot writeup was generated"
    e.text = unicode(
        render_to_string("doc/mail/ballot_writeup.txt", {'iana': iana}))

    # caller is responsible for saving, if necessary
    return e
示例#21
0
def ballot_approvaltext(request, name):
    """Editing of approval text"""
    doc = get_object_or_404(Document, docalias__name=name)
    if not doc.get_state("draft-iesg"):
        raise Http404()

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent, type="changed_ballot_approval_text")
    if not existing:
        existing = generate_approval_mail(request, doc)

    form = ApprovalTextForm(initial=dict(approval_text=existing.text))

    if request.method == 'POST':
        if "save_approval_text" in request.POST:
            form = ApprovalTextForm(request.POST)
            if form.is_valid():
                t = form.cleaned_data['approval_text']
                if t != existing.text:
                    e = WriteupDocEvent(doc=doc, by=login)
                    e.by = login
                    e.type = "changed_ballot_approval_text"
                    e.desc = "Ballot approval text was changed"
                    e.text = t
                    e.save()
                
        if "regenerate_approval_text" in request.POST:
            e = generate_approval_mail(request, doc)

            # make sure form has the updated text
            form = ApprovalTextForm(initial=dict(approval_text=e.text))

    can_announce = doc.get_state("draft-iesg").order > 19
    need_intended_status = ""
    if not doc.intended_std_level:
        need_intended_status = doc.file_tag()

    return render_to_response('doc/ballot/approvaltext.html',
                              dict(doc=doc,
                                   back_url=doc.get_absolute_url(),
                                   approval_text_form=form,
                                   can_announce=can_announce,
                                   need_intended_status=need_intended_status,
                                   ),
                              context_instance=RequestContext(request))
示例#22
0
def generate_approval_mailREDESIGN(request, doc):
    if doc.get_state_slug(
            "draft-iesg") in DO_NOT_PUBLISH_IESG_STATES or doc.stream_id in (
                'ise', 'irtf'):
        mail = generate_approval_mail_rfc_editor(request, doc)
    else:
        mail = generate_approval_mail_approved(request, doc)

    e = WriteupDocEvent()
    e.type = "changed_ballot_approval_text"
    e.by = request.user.get_profile()
    e.doc = doc
    e.desc = u"Ballot approval text was generated"
    e.text = unicode(mail)
    e.save()

    return e
示例#23
0
文件: mails.py 项目: ekr/ietfdb
def generate_approval_mail(request, doc):
    if doc.get_state_slug(
            "draft-iesg") in DO_NOT_PUBLISH_IESG_STATES or doc.stream_id in (
                'ise', 'irtf'):
        mail = generate_approval_mail_rfc_editor(request, doc)
    else:
        mail = generate_approval_mail_approved(request, doc)

    e = WriteupDocEvent()
    e.type = "changed_ballot_approval_text"
    e.by = request.user.person
    e.doc = doc
    e.rev = doc.rev
    e.desc = u"Ballot approval text was generated"
    e.text = unicode(mail)

    # caller is responsible for saving, if necessary
    return e
示例#24
0
文件: forms.py 项目: mcr/ietfdb
    def save(self):
        if settings.USE_DB_REDESIGN_PROXY_CLASSES:
            e = WriteupDocEvent(type="changed_protocol_writeup")
            e.doc = self.doc
            e.by = self.person
            e.desc = e.get_type_display()
            e.text = self.cleaned_data['writeup']
            e.save()
            from ietf.wgchairs.models import ProtoWriteUpProxy
            self.doc_writeup = ProtoWriteUpProxy.objects.get(pk=e.pk)
        else:
            if not self.doc_writeup:
                self.doc_writeup = ProtoWriteUp.objects.create(
                    person=self.person,
                    draft=self.doc,
                    writeup=self.cleaned_data['writeup'])
            else:
                self.doc_writeup.writeup = self.cleaned_data['writeup']
                self.doc_writeup.save()

        if self.data.get('modify_tag', False):
            followup = self.cleaned_data.get('followup', False)
            comment = self.cleaned_data.get('comment', False)
            try:
                shepherd = self.doc.shepherd
            except PersonOrOrgInfo.DoesNotExist:
                shepherd = None
            if shepherd:
                if settings.USE_DB_REDESIGN_PROXY_CLASSES:
                    extra_notify = [shepherd.formatted_email()]
                else:
                    extra_notify = ['%s <%s>' % shepherd.email()]
            else:
                extra_notify = []
            if settings.USE_DB_REDESIGN_PROXY_CLASSES:
                tags = DocTagName.objects.filter(slug="sheph-u")
            else:
                tags = [FOLLOWUP_TAG]
            if followup:
                update_tags(self.request, self.doc, comment, self.person, set_tags=tags, extra_notify=extra_notify)
            else:
                update_tags(self.request, self.doc, comment, self.person, reset_tags=tags, extra_notify=extra_notify)
        return self.doc_writeup
示例#25
0
文件: mails.py 项目: mcr/ietfdb
def generate_last_call_announcementREDESIGN(request, doc):
    
    expiration_date = date.today() + timedelta(days=14)
    cc = []
    if doc.group.type_id in ("individ", "area"):
        group = "an individual submitter"
        expiration_date += timedelta(days=14)
    else:
        group = "the %s WG (%s)" % (doc.group.name, doc.group.acronym)
        if doc.group.list_email:
            cc.append(doc.group.list_email)

    doc.filled_title = textwrap.fill(doc.title, width=70, subsequent_indent=" " * 3)
    
    iprs, _ = iprs_from_docs(related_docs(DocAlias.objects.get(name=doc.canonical_name()),[]))
    if iprs:
        ipr_links = [ urlreverse("ietf.ipr.views.show", kwargs=dict(ipr_id=i.ipr_id)) for i in iprs]
        ipr_links = [ settings.IDTRACKER_BASE_URL+url if not url.startswith("http") else url for url in ipr_links ]
    else:
        ipr_links = None

    mail = render_to_string("idrfc/last_call_announcement.txt",
                            dict(doc=doc,
                                 doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url() + "ballot/",
                                 expiration_date=expiration_date.strftime("%Y-%m-%d"), #.strftime("%B %-d, %Y"),
                                 cc=", ".join("<%s>" % e for e in cc),
                                 group=group,
                                 docs=[ doc ],
                                 urls=[ settings.IDTRACKER_BASE_URL + doc.get_absolute_url() ],
                                 ipr_links=ipr_links,
                                 )
                            )

    e = WriteupDocEvent()
    e.type = "changed_last_call_text"
    e.by = request.user.get_profile()
    e.doc = doc
    e.desc = u"Last call announcement was generated"
    e.text = unicode(mail)
    e.save()

    return e
示例#26
0
def default_review_text(group, charter, by):
    e = WriteupDocEvent(doc=charter, by=by)
    e.by = by
    e.type = "changed_review_announcement"
    e.desc = "%s review text was changed" % group.type.name
    e.text = render_to_string("doc/charter/review_text.txt",
                              dict(group=group,
                                   charter_url=settings.IDTRACKER_BASE_URL + charter.get_absolute_url(),
                                   charter_text=read_charter_text(charter),
                                   chairs=group.role_set.filter(name="chair"),
                                   secr=group.role_set.filter(name="secr"),
                                   techadv=group.role_set.filter(name="techadv"),
                                   milestones=group.groupmilestone_set.filter(state="charter"),
                                   ad_email=group.ad.role_email("ad") if group.ad else None,
                                   review_date=(datetime.date.today() + datetime.timedelta(weeks=1)).isoformat(),
                                   review_type="new" if group.state_id == "proposed" else "recharter",
                                   )
                              )
    e.save()
    return e
示例#27
0
def generate_last_call_announcement(request, doc):
    expiration_date = datetime.date.today() + datetime.timedelta(days=14)
    if doc.group.type_id in ("individ", "area"):
        group = "an individual submitter"
        expiration_date += datetime.timedelta(days=14)
    else:
        group = "the %s %s (%s)" % (doc.group.name, doc.group.type.name, doc.group.acronym)

    doc.filled_title = textwrap.fill(doc.title, width=70, subsequent_indent=" " * 3)
    
    iprs = iprs_from_docs(related_docs(DocAlias.objects.get(name=doc.canonical_name())))
    if iprs:
        ipr_links = [ urlreverse("ietf.ipr.views.show", kwargs=dict(id=i.id)) for i in iprs]
        ipr_links = [ settings.IDTRACKER_BASE_URL+url if not url.startswith("http") else url for url in ipr_links ]
    else:
        ipr_links = None


    addrs = gather_address_lists('last_call_issued',doc=doc).as_strings()
    mail = render_to_string("doc/mail/last_call_announcement.txt",
                            dict(doc=doc,
                                 doc_url=settings.IDTRACKER_BASE_URL + doc.get_absolute_url() + "ballot/",
                                 expiration_date=expiration_date.strftime("%Y-%m-%d"), #.strftime("%B %-d, %Y"),
                                 to=addrs.to,
                                 cc=addrs.cc,
                                 group=group,
                                 docs=[ doc ],
                                 urls=[ settings.IDTRACKER_BASE_URL + doc.get_absolute_url() ],
                                 ipr_links=ipr_links,
                                 )
                            )

    e = WriteupDocEvent()
    e.type = "changed_last_call_text"
    e.by = request.user.person
    e.doc = doc
    e.desc = u"Last call announcement was generated"
    e.text = unicode(mail)
    e.save()

    return e
示例#28
0
def generate_last_call_text(request, doc):

    # requester should be set based on doc.group once the group for a status change can be set to something other than the IESG
    # and when groups are set, vary the expiration time accordingly

    requester = "an individual participant"
    expiration_date = datetime.date.today() + datetime.timedelta(days=28)
    cc = []

    new_text = render_to_string(
        "doc/status_change/last_call_announcement.txt",
        dict(doc=doc,
             settings=settings,
             requester=requester,
             expiration_date=expiration_date.strftime("%Y-%m-%d"),
             changes=[
                 '%s from %s to %s\n    (%s)' %
                 (rel.target.name.upper(), rel.target.document.std_level.name,
                  newstatus(rel), rel.target.document.title)
                 for rel in doc.relateddocument_set.filter(
                     relationship__slug__in=STATUSCHANGE_RELATIONS)
             ],
             urls=[
                 rel.target.document.get_absolute_url()
                 for rel in doc.relateddocument_set.filter(
                     relationship__slug__in=STATUSCHANGE_RELATIONS)
             ],
             cc=cc))

    e = WriteupDocEvent()
    e.type = 'changed_last_call_text'
    e.by = request.user.person
    e.doc = doc
    e.rev = doc.rev
    e.desc = 'Last call announcement was generated'
    e.text = unicode(new_text)
    e.save()

    return e
示例#29
0
def default_review_text(group, charter, user):
    e = WriteupDocEvent(doc=charter, by=user)
    e.by = user
    e.type = "changed_review_announcement"
    e.desc = "%s review text was changed" % group.type.name
    e.text = render_to_string(
        "wgcharter/review_text.txt",
        dict(
            group=group,
            charter_url=settings.IDTRACKER_BASE_URL +
            charter.get_absolute_url(),
            charter_text=read_charter_text(charter),
            chairs=group.role_set.filter(name="chair"),
            secr=group.role_set.filter(name="secr"),
            techadv=group.role_set.filter(name="techadv"),
            milestones=group.groupmilestone_set.filter(state="charter"),
            ad_email=group.ad.role_email("ad") if group.ad else None,
            review_date=(datetime.date.today() +
                         datetime.timedelta(weeks=1)).isoformat(),
            review_type="new" if group.state_id == "proposed" else "recharter",
        ))
    e.save()
    return e
示例#30
0
def default_action_text(group, charter, by):
    if next_approved_revision(group.charter.rev) == "01":
        action = "Formed"
    else:
        action = "Rechartered"

    e = WriteupDocEvent(doc=charter, by=by)
    e.by = by
    e.type = "changed_action_announcement"
    e.desc = "%s action text was changed" % group.type.name
    e.text = render_to_string("doc/charter/action_text.txt",
                              dict(group=group,
                                   charter_url=settings.IDTRACKER_BASE_URL + charter.get_absolute_url(),
                                   charter_text=read_charter_text(charter),
                                   chairs=group.role_set.filter(name="chair"),
                                   secr=group.role_set.filter(name="secr"),
                                   techadv=group.role_set.filter(name="techadv"),
                                   milestones=group.groupmilestone_set.filter(state="charter"),
                                   ad_email=group.ad.role_email("ad") if group.ad else None,
                                   action_type=action,
                                   ))

    e.save()
    return e
示例#31
0
def default_action_text(group, charter, by):
    if next_approved_revision(group.charter.rev) == "01":
        action = "Formed"
    else:
        action = "Rechartered"

    addrs = gather_address_lists('ballot_approved_charter',
                                 doc=charter,
                                 group=group).as_strings(compact=False)
    e = WriteupDocEvent(doc=charter, rev=charter.rev, by=by)
    e.by = by
    e.type = "changed_action_announcement"
    e.desc = "%s action text was changed" % group.type.name
    e.text = render_to_string(
        "doc/charter/action_text.txt",
        dict(
            group=group,
            group_url=settings.IDTRACKER_BASE_URL +
            urlreverse('ietf.group.views.group_home',
                       kwargs=dict(acronym=group.acronym)),
            charter_url=settings.IDTRACKER_BASE_URL +
            charter.get_absolute_url(),
            charter_text=read_charter_text(charter),
            chairs=group.role_set.filter(name="chair"),
            secr=group.role_set.filter(name="secr"),
            techadv=group.role_set.filter(name="techadv"),
            ads=group.role_set.filter(name='ad'),
            parent_ads=group.parent.role_set.filter(name='ad'),
            milestones=group.groupmilestone_set.filter(state="charter"),
            action_type=action,
            to=addrs.to,
            cc=addrs.cc,
        ))

    # caller is responsible for saving, if necessary
    return e
示例#32
0
def last_call(request, name):
    """Edit the Last Call Text for this status change and possibly request IETF LC"""

    status_change = get_object_or_404(Document, type="statchg", name=name)

    login = request.user.person

    last_call_event = status_change.latest_event(WriteupDocEvent,
                                                 type="changed_last_call_text")
    if not last_call_event:
        last_call_event = generate_last_call_text(request, status_change)

    form = LastCallTextForm(initial=dict(last_call_text=last_call_event.text))

    if request.method == 'POST':
        if "save_last_call_text" in request.POST or "send_last_call_request" in request.POST:
            form = LastCallTextForm(request.POST)
            if form.is_valid():
                events = []

                t = form.cleaned_data['last_call_text']
                if t != last_call_event.text:
                    e = WriteupDocEvent(doc=status_change,
                                        rev=status_change.rev,
                                        by=login)
                    e.by = login
                    e.type = "changed_last_call_text"
                    e.desc = "Last call announcement was changed"
                    e.text = t
                    e.save()

                    events.append(e)

                if "send_last_call_request" in request.POST:
                    prev_state = status_change.get_state()
                    new_state = State.objects.get(type='statchg',
                                                  slug='lc-req')

                    status_change.set_state(new_state)
                    e = add_state_change_event(status_change, login,
                                               prev_state, new_state)
                    if e:
                        events.append(e)

                    if events:
                        status_change.save_with_history(events)

                    request_last_call(request, status_change)

                    return render(
                        request, 'doc/draft/last_call_requested.html',
                        dict(
                            doc=status_change,
                            url=status_change.get_absolute_url(),
                        ))

        if "regenerate_last_call_text" in request.POST:
            e = generate_last_call_text(request, status_change)
            form = LastCallTextForm(initial=dict(last_call_text=e.text))

    return render(
        request,
        'doc/status_change/last_call.html',
        dict(
            doc=status_change,
            back_url=status_change.get_absolute_url(),
            last_call_event=last_call_event,
            last_call_form=form,
        ),
    )
示例#33
0
def last_call(request, name):
    """Edit the Last Call Text for this status change and possibly request IETF LC"""

    status_change = get_object_or_404(Document, type="statchg", name=name)

    login = request.user.get_profile()

    last_call_event = status_change.latest_event(WriteupDocEvent,
                                                 type="changed_last_call_text")
    if not last_call_event:
        last_call_event = generate_last_call_text(request, status_change)

    form = LastCallTextForm(initial=dict(last_call_text=last_call_event.text))

    if request.method == 'POST':
        if "save_last_call_text" in request.POST or "send_last_call_request" in request.POST:
            form = LastCallTextForm(request.POST)
            if form.is_valid():
                t = form.cleaned_data['last_call_text']
                if t != last_call_event.text:
                    e = WriteupDocEvent(doc=status_change, by=login)
                    e.by = login
                    e.type = "changed_last_call_text"
                    e.desc = "Last call announcement was changed"
                    e.text = t
                    e.save()

                if "send_last_call_request" in request.POST:
                    save_document_in_history(status_change)

                    old_description = status_change.friendly_state()
                    status_change.set_state(
                        State.objects.get(type='statchg', slug='lc-req'))
                    new_description = status_change.friendly_state()

                    e = log_state_changed(request, status_change, login,
                                          new_description, old_description)

                    status_change.time = e.time
                    status_change.save()

                    request_last_call(request, status_change)

                    return render_to_response(
                        'idrfc/last_call_requested.html',
                        dict(
                            doc=status_change,
                            url=status_change.get_absolute_url(),
                        ),
                        context_instance=RequestContext(request))

        if "regenerate_last_call_text" in request.POST:
            e = generate_last_call_text(request, status_change)
            form = LastCallTextForm(initial=dict(last_call_text=e.text))

    return render_to_response('doc/status_change/last_call.html',
                              dict(
                                  doc=status_change,
                                  back_url=status_change.get_absolute_url(),
                                  last_call_event=last_call_event,
                                  last_call_form=form,
                              ),
                              context_instance=RequestContext(request))
示例#34
0
def ballot_writeupnotes(request, name):
    """Editing of ballot write-up and notes"""
    doc = get_object_or_404(Document, docalias__name=name)

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent,
                                type="changed_ballot_writeup_text")
    if not existing:
        existing = generate_ballot_writeup(request, doc)

    form = BallotWriteupForm(initial=dict(ballot_writeup=existing.text))

    if request.method == 'POST' and "save_ballot_writeup" in request.POST or "issue_ballot" in request.POST:
        form = BallotWriteupForm(request.POST)
        if form.is_valid():
            t = form.cleaned_data["ballot_writeup"]
            if t != existing.text:
                e = WriteupDocEvent(doc=doc, rev=doc.rev, by=login)
                e.by = login
                e.type = "changed_ballot_writeup_text"
                e.desc = "Ballot writeup was changed"
                e.text = t
                e.save()
            elif existing.pk == None:
                existing.save()

            if "issue_ballot" in request.POST:
                create_ballot_if_not_open(doc, login, "approve")
                ballot = doc.latest_event(BallotDocEvent,
                                          type="created_ballot")

                if has_role(
                        request.user,
                        "Area Director") and not doc.latest_event(
                            BallotPositionDocEvent, ad=login, ballot=ballot):
                    # sending the ballot counts as a yes
                    pos = BallotPositionDocEvent(doc=doc,
                                                 rev=doc.rev,
                                                 by=login)
                    pos.ballot = ballot
                    pos.type = "changed_ballot_position"
                    pos.ad = login
                    pos.pos_id = "yes"
                    pos.desc = "[Ballot Position Update] New position, %s, has been recorded for %s" % (
                        pos.pos.name, pos.ad.plain_name())
                    pos.save()

                    # Consider mailing this position to 'ballot_saved'

                approval = doc.latest_event(
                    WriteupDocEvent, type="changed_ballot_approval_text")
                if not approval:
                    approval = generate_approval_mail(request, doc)
                    approval.save()

                msg = generate_issue_ballot_mail(request, doc, ballot)

                addrs = gather_address_lists('ballot_issued',
                                             doc=doc).as_strings()
                override = {'To': addrs.to}
                if addrs.cc:
                    override['CC'] = addrs.cc
                send_mail_preformatted(request, msg, override=override)

                addrs = gather_address_lists('ballot_issued_iana',
                                             doc=doc).as_strings()
                override = {
                    "To": "IANA <%s>" % settings.IANA_EVAL_EMAIL,
                    "Bcc": None,
                    "Reply-To": None
                }
                if addrs.cc:
                    override['CC'] = addrs.cc
                send_mail_preformatted(request,
                                       msg,
                                       extra=extra_automation_headers(doc),
                                       override={
                                           "To": "IANA <%s>" %
                                           settings.IANA_EVAL_EMAIL,
                                           "CC": None,
                                           "Bcc": None,
                                           "Reply-To": None
                                       })

                e = DocEvent(doc=doc, rev=doc.rev, by=login)
                e.by = login
                e.type = "sent_ballot_announcement"
                e.desc = "Ballot has been issued"
                e.save()

                return render(request, 'doc/ballot/ballot_issued.html',
                              dict(doc=doc, back_url=doc.get_absolute_url()))

    need_intended_status = ""
    if not doc.intended_std_level:
        need_intended_status = doc.file_tag()

    return render(
        request, 'doc/ballot/writeupnotes.html',
        dict(
            doc=doc,
            back_url=doc.get_absolute_url(),
            ballot_issued=bool(
                doc.latest_event(type="sent_ballot_announcement")),
            ballot_writeup_form=form,
            need_intended_status=need_intended_status,
        ))
示例#35
0
def lastcalltext(request, name):
    """Editing of the last call text"""
    doc = get_object_or_404(Document, docalias__name=name)
    if not doc.get_state("draft-iesg"):
        raise Http404

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent, type="changed_last_call_text")
    if not existing:
        existing = generate_last_call_announcement(request, doc)

    form = LastCallTextForm(initial=dict(last_call_text=existing.text))

    if request.method == 'POST':
        if "save_last_call_text" in request.POST or "send_last_call_request" in request.POST:
            form = LastCallTextForm(request.POST)
            if form.is_valid():
                t = form.cleaned_data['last_call_text']
                if t != existing.text:
                    e = WriteupDocEvent(doc=doc, rev=doc.rev, by=login)
                    e.by = login
                    e.type = "changed_last_call_text"
                    e.desc = "Last call announcement was changed"
                    e.text = t
                    e.save()
                elif existing.pk == None:
                    existing.save()

                if "send_last_call_request" in request.POST:
                    prev_state = doc.get_state("draft-iesg")
                    new_state = State.objects.get(used=True,
                                                  type="draft-iesg",
                                                  slug='lc-req')

                    prev_tags = doc.tags.filter(slug__in=IESG_SUBSTATE_TAGS)

                    doc.set_state(new_state)
                    doc.tags.remove(*prev_tags)

                    e = add_state_change_event(doc,
                                               login,
                                               prev_state,
                                               new_state,
                                               prev_tags=prev_tags,
                                               new_tags=[])

                    if e:
                        doc.save_with_history([e])

                    request_last_call(request, doc)

                    return render(request,
                                  'doc/draft/last_call_requested.html',
                                  dict(doc=doc))

        if "regenerate_last_call_text" in request.POST:
            e = generate_last_call_announcement(request, doc)
            e.save()

            # make sure form has the updated text
            form = LastCallTextForm(initial=dict(last_call_text=e.text))

    s = doc.get_state("draft-iesg")
    can_request_last_call = s.order < 27
    can_make_last_call = s.order < 20

    need_intended_status = ""
    if not doc.intended_std_level:
        need_intended_status = doc.file_tag()

    return render(
        request, 'doc/ballot/lastcalltext.html',
        dict(
            doc=doc,
            back_url=doc.get_absolute_url(),
            last_call_form=form,
            can_request_last_call=can_request_last_call,
            can_make_last_call=can_make_last_call,
            need_intended_status=need_intended_status,
        ))
示例#36
0
def review_announcement_text(request, name):
    """Editing of review announcement text"""
    charter = get_object_or_404(Document, type="charter", name=name)
    group = charter.group

    by = request.user.person

    existing = charter.latest_event(WriteupDocEvent,
                                    type="changed_review_announcement")
    existing_new_work = charter.latest_event(WriteupDocEvent,
                                             type="changed_new_work_text")

    if not existing:
        (existing, existing_new_work) = default_review_text(group, charter, by)

    if not existing:
        raise Http404

    if not existing_new_work:
        existing_new_work = WriteupDocEvent(doc=charter, rev=charter.rev)
        existing_new_work.by = by
        existing_new_work.type = "changed_new_work_text"
        existing_new_work.desc = "%s review text was changed" % group.type.name
        existing_new_work.text = derive_new_work_text(existing.text, group)
        existing_new_work.time = datetime.datetime.now()

    form = ReviewAnnouncementTextForm(initial=dict(
        announcement_text=existing.text, new_work_text=existing_new_work.text))

    if request.method == 'POST':
        form = ReviewAnnouncementTextForm(request.POST)
        if "save_text" in request.POST and form.is_valid():

            now = datetime.datetime.now()
            events = []

            t = form.cleaned_data['announcement_text']
            if t != existing.text:
                e = WriteupDocEvent(doc=charter, rev=charter.rev)
                e.by = by
                e.type = "changed_review_announcement"
                e.desc = "%s review text was changed" % (group.type.name)
                e.text = t
                e.time = now
                e.save()
                events.append(e)
            elif existing.pk is None:
                existing.save()
                events.append(existing)

            t = form.cleaned_data['new_work_text']
            if t != existing_new_work.text:
                e = WriteupDocEvent(doc=charter, rev=charter.rev)
                e.by = by
                e.type = "changed_new_work_text"
                e.desc = "%s new work message text was changed" % (
                    group.type.name)
                e.text = t
                e.time = now
                e.save()
            elif existing_new_work.pk is None:
                existing_new_work.save()
                events.append(existing_new_work)

            if events:
                charter.save_with_history(events)

            if request.GET.get("next", "") == "approve":
                return redirect('ietf.doc.views_charter.approve',
                                name=charter.canonical_name())

            return redirect('ietf.doc.views_doc.document_writeup',
                            name=charter.canonical_name())

        if "regenerate_text" in request.POST:
            (existing,
             existing_new_work) = default_review_text(group, charter, by)
            existing.save()
            existing_new_work.save()
            form = ReviewAnnouncementTextForm(
                initial=dict(announcement_text=existing.text,
                             new_work_text=existing_new_work.text))

        if any(x in request.POST
               for x in ['send_annc_only', 'send_nw_only', 'send_both'
                         ]) and form.is_valid():
            if any(x in request.POST for x in ['send_annc_only', 'send_both']):
                parsed_msg = send_mail_preformatted(
                    request, form.cleaned_data['announcement_text'])
                messages.success(
                    request,
                    "The email To: '%s' with Subject: '%s' has been sent." % (
                        parsed_msg["To"],
                        parsed_msg["Subject"],
                    ))
            if any(x in request.POST for x in ['send_nw_only', 'send_both']):
                parsed_msg = send_mail_preformatted(
                    request, form.cleaned_data['new_work_text'])
                messages.success(
                    request,
                    "The email To: '%s' with Subject: '%s' has been sent." % (
                        parsed_msg["To"],
                        parsed_msg["Subject"],
                    ))
            return redirect('ietf.doc.views_doc.document_writeup',
                            name=charter.name)

    return render(
        request, 'doc/charter/review_announcement_text.html',
        dict(
            charter=charter,
            back_url=urlreverse('ietf.doc.views_doc.document_writeup',
                                kwargs=dict(name=charter.name)),
            announcement_text_form=form,
        ))
示例#37
0
def action_announcement_text(request, name):
    """Editing of action announcement text"""
    charter = get_object_or_404(Document, type="charter", name=name)
    group = charter.group

    by = request.user.person

    existing = charter.latest_event(WriteupDocEvent,
                                    type="changed_action_announcement")
    if not existing:
        existing = default_action_text(group, charter, by)

    if not existing:
        raise Http404

    form = ActionAnnouncementTextForm(initial=dict(
        announcement_text=existing.text))

    if request.method == 'POST':
        form = ActionAnnouncementTextForm(request.POST)
        if "save_text" in request.POST and form.is_valid():
            t = form.cleaned_data['announcement_text']
            if t != existing.text:
                e = WriteupDocEvent(doc=charter, rev=charter.rev)
                e.by = by
                e.type = "changed_action_announcement"
                e.desc = "%s action text was changed" % group.type.name
                e.text = t
                e.save()
            elif existing.pk == None:
                existing.save()

            if request.GET.get("next", "") == "approve":
                return redirect('ietf.doc.views_charter.approve',
                                name=charter.canonical_name())

            return redirect('ietf.doc.views_doc.document_writeup',
                            name=charter.canonical_name())

        if "regenerate_text" in request.POST:
            e = default_action_text(group, charter, by)
            e.save()
            form = ActionAnnouncementTextForm(initial=dict(
                announcement_text=e.text))

        if "send_text" in request.POST and form.is_valid():
            parsed_msg = send_mail_preformatted(
                request, form.cleaned_data['announcement_text'])
            messages.success(
                request,
                "The email To: '%s' with Subject: '%s' has been sent." % (
                    parsed_msg["To"],
                    parsed_msg["Subject"],
                ))
            return redirect('ietf.doc.views_doc.document_writeup',
                            name=charter.name)

    return render(
        request, 'doc/charter/action_announcement_text.html',
        dict(
            charter=charter,
            back_url=urlreverse('ietf.doc.views_doc.document_writeup',
                                kwargs=dict(name=charter.name)),
            announcement_text_form=form,
        ))
示例#38
0
def ballot_writeupnotes(request, name):
    """Editing of ballot write-up and notes"""
    charter = get_object_or_404(Document, type="charter", name=name)

    ballot = charter.latest_event(BallotDocEvent, type="created_ballot")
    if not ballot:
        raise Http404

    by = request.user.person

    approval = charter.latest_event(WriteupDocEvent,
                                    type="changed_action_announcement")

    existing = charter.latest_event(WriteupDocEvent,
                                    type="changed_ballot_writeup_text")
    if not existing:
        existing = generate_ballot_writeup(request, charter)

    reissue = charter.latest_event(DocEvent, type="sent_ballot_announcement")

    form = BallotWriteupForm(initial=dict(ballot_writeup=existing.text))

    if request.method == 'POST' and ("save_ballot_writeup" in request.POST
                                     or "send_ballot" in request.POST):
        form = BallotWriteupForm(request.POST)
        if form.is_valid():
            t = form.cleaned_data["ballot_writeup"]
            if t != existing.text:
                e = WriteupDocEvent(doc=charter, rev=charter.rev, by=by)
                e.type = "changed_ballot_writeup_text"
                e.desc = "Ballot writeup was changed"
                e.text = t
                e.save()

                existing = e
            elif existing.pk == None:
                existing.save()

            if "send_ballot" in request.POST and approval:
                if has_role(request.user,
                            "Area Director") and not charter.latest_event(
                                BallotPositionDocEvent,
                                type="changed_ballot_position",
                                ad=by,
                                ballot=ballot):
                    # sending the ballot counts as a yes
                    pos = BallotPositionDocEvent(doc=charter,
                                                 rev=charter.rev,
                                                 by=by)
                    pos.type = "changed_ballot_position"
                    pos.ad = by
                    pos.pos_id = "yes"
                    pos.desc = "[Ballot Position Update] New position, %s, has been recorded for %s" % (
                        pos.pos.name, pos.ad.plain_name())
                    pos.save()
                    # Consider mailing this position to 'ballot_saved'

                msg = generate_issue_ballot_mail(request, charter, ballot)
                send_mail_preformatted(request, msg)

                e = DocEvent(doc=charter, rev=charter.rev, by=by)
                e.by = by
                e.type = "sent_ballot_announcement"
                e.desc = "Ballot has been sent"
                e.save()

                return render(request, 'doc/charter/ballot_issued.html',
                              dict(doc=charter, ))

    return render(
        request, 'doc/charter/ballot_writeupnotes.html',
        dict(
            charter=charter,
            ballot_issued=bool(
                charter.latest_event(type="sent_ballot_announcement")),
            ballot_writeup_form=form,
            reissue=reissue,
            approval=approval,
        ))
示例#39
0
def review_announcement_text(request, name):
    """Editing of review announcement text"""
    charter = get_object_or_404(Document, type="charter", name=name)
    group = charter.group

    login = request.user.person

    existing = charter.latest_event(WriteupDocEvent, type="changed_review_announcement")
    existing_new_work = charter.latest_event(WriteupDocEvent, type="changed_new_work_text")

    if not existing:
        (existing, existing_new_work) = default_review_text(group, charter, login)

    if not existing:
        raise Http404

    if not existing_new_work:
        existing_new_work = WriteupDocEvent(doc=charter, by=login)
        existing_new_work.by = login 
        existing_new_work.type = "changed_new_work_text"
        existing_new_work.desc = "%s review text was changed" % group.type.name
        existing_new_work.text = derive_new_work_text(existing.text,group)
        existing_new_work.time = datetime.datetime.now()
        existing_new_work.save()

    new_work_text = existing_new_work.text

    form = ReviewAnnouncementTextForm(initial=dict(announcement_text=existing.text,new_work_text=new_work_text))

    if request.method == 'POST':
        form = ReviewAnnouncementTextForm(request.POST)
        if "save_text" in request.POST and form.is_valid():

            now = datetime.datetime.now()
            (e1, e2) = (None, None)

            t = form.cleaned_data['announcement_text']
            if t != existing.text:
                e1 = WriteupDocEvent(doc=charter, by=login)
                e1.by = login
                e1.type = "changed_review_announcement" 
                e1.desc = "%s review text was changed" % (group.type.name)
                e1.text = t
                e1.time = now
                e1.save()

            t = form.cleaned_data['new_work_text']
            if t != new_work_text:
                e2 = WriteupDocEvent(doc=charter, by=login)
                e2.by = login
                e2.type = "changed_new_work_text" 
                e2.desc = "%s new work message text was changed" % (group.type.name)
                e2.text = t
                e2.time = now
                e2.save()

            if e1 or e2:
                charter.time = now
                charter.save()

            if request.GET.get("next", "") == "approve":
                return redirect('charter_approve', name=charter.canonical_name())

            return redirect('doc_writeup', name=charter.canonical_name())

        if "regenerate_text" in request.POST:
            (e1, e2) = default_review_text(group, charter, login)
            form = ReviewAnnouncementTextForm(initial=dict(announcement_text=e1.text,new_work_text=e2.text))

        if any([x in request.POST for x in ['send_annc_only','send_nw_only','send_both']]) and form.is_valid():
            if any([x in request.POST for x in ['send_annc_only','send_both']]):
                parsed_msg = send_mail_preformatted(request, form.cleaned_data['announcement_text'])
                messages.success(request, "The email To: '%s' with Subject: '%s' has been sent." % (parsed_msg["To"],parsed_msg["Subject"],))
            if any([x in request.POST for x in ['send_nw_only','send_both']]):
                parsed_msg = send_mail_preformatted(request, form.cleaned_data['new_work_text'])
                messages.success(request, "The email To: '%s' with Subject: '%s' has been sent." % (parsed_msg["To"],parsed_msg["Subject"],))
            return redirect('doc_writeup', name=charter.name)

    return render_to_response('doc/charter/review_announcement_text.html',
                              dict(charter=charter,
                                   back_url=urlreverse("doc_writeup", kwargs=dict(name=charter.name)),
                                   announcement_text_form=form,
                                   ),
                              context_instance=RequestContext(request))
示例#40
0
def ballot_writeupnotes(request, name):
    """Editing of ballot write-up and notes"""
    charter = get_object_or_404(Document, type="charter", name=name)

    ballot = charter.latest_event(BallotDocEvent, type="created_ballot")
    if not ballot:
        raise Http404

    login = request.user.person

    approval = charter.latest_event(WriteupDocEvent, type="changed_action_announcement")

    existing = charter.latest_event(WriteupDocEvent, type="changed_ballot_writeup_text")
    if not existing:
        existing = generate_ballot_writeup(request, charter)

    reissue = charter.latest_event(DocEvent, type="sent_ballot_announcement")

    form = BallotWriteupForm(initial=dict(ballot_writeup=existing.text))

    if request.method == 'POST' and ("save_ballot_writeup" in request.POST or "send_ballot" in request.POST):
        form = BallotWriteupForm(request.POST)
        if form.is_valid():
            t = form.cleaned_data["ballot_writeup"]
            if t != existing.text:
                e = WriteupDocEvent(doc=charter, by=login)
                e.by = login
                e.type = "changed_ballot_writeup_text"
                e.desc = "Ballot writeup was changed"
                e.text = t
                e.save()

                existing = e

            if "send_ballot" in request.POST and approval:
                if has_role(request.user, "Area Director") and not charter.latest_event(BallotPositionDocEvent, type="changed_ballot_position", ad=login, ballot=ballot):
                    # sending the ballot counts as a yes
                    pos = BallotPositionDocEvent(doc=charter, by=login)
                    pos.type = "changed_ballot_position"
                    pos.ad = login
                    pos.pos_id = "yes"
                    pos.desc = "[Ballot Position Update] New position, %s, has been recorded for %s" % (pos.pos.name, pos.ad.plain_name())
                    pos.save()
                    # Consider mailing this position to 'ballot_saved'

                msg = generate_issue_ballot_mail(request, charter, ballot)
                send_mail_preformatted(request, msg)

                e = DocEvent(doc=charter, by=login)
                e.by = login
                e.type = "sent_ballot_announcement"
                e.desc = "Ballot has been sent"
                e.save()

                return render_to_response('doc/charter/ballot_issued.html',
                                          dict(doc=charter,
                                               ),
                                          context_instance=RequestContext(request))

    return render_to_response('doc/charter/ballot_writeupnotes.html',
                              dict(charter=charter,
                                   ballot_issued=bool(charter.latest_event(type="sent_ballot_announcement")),
                                   ballot_writeup_form=form,
                                   reissue=reissue,
                                   approval=approval,
                                   ),
                              context_instance=RequestContext(request))
示例#41
0
    def test_edit_verify_permissions(self):
        def verify_fail(username, url):
            if username:
                self.client.login(username=username,
                                  password=username + "+password")
            r = self.client.get(url)
            self.assertEqual(r.status_code, 403)

        def verify_can_see(username, url):
            self.client.login(username=username,
                              password=username + "+password")
            r = self.client.get(url)
            self.assertEqual(r.status_code, 200)
            q = PyQuery(r.content)
            self.assertEqual(len(q("<textarea class=\"form-control\"")), 1)

        draft = make_test_data()

        events = []

        e = WriteupDocEvent()
        e.type = "changed_ballot_approval_text"
        e.by = Person.objects.get(name="(System)")
        e.doc = draft
        e.rev = draft.rev
        e.desc = u"Ballot approval text was generated"
        e.text = u"Test approval text."
        e.save()
        events.append(e)

        e = WriteupDocEvent()
        e.type = "changed_ballot_writeup_text"
        e.by = Person.objects.get(name="(System)")
        e.doc = draft
        e.rev = draft.rev
        e.desc = u"Ballot writeup was generated"
        e.text = u"Test ballot writeup text."
        e.save()
        events.append(e)

        e = WriteupDocEvent()
        e.type = "changed_ballot_rfceditornote_text"
        e.by = Person.objects.get(name="(System)")
        e.doc = draft
        e.rev = draft.rev
        e.desc = u"RFC Editor Note for ballot was generated"
        e.text = u"Test note to the RFC Editor text."
        e.save()
        events.append(e)

        # IETF Stream Documents
        for p in [
                'ietf.doc.views_ballot.ballot_approvaltext',
                'ietf.doc.views_ballot.ballot_writeupnotes',
                'ietf.doc.views_ballot.ballot_rfceditornote'
        ]:
            url = urlreverse(p, kwargs=dict(name=draft.name))

            for username in [
                    'plain', 'marschairman', 'iab chair', 'irtf chair', 'ise',
                    'iana'
            ]:
                verify_fail(username, url)

            for username in ['secretary', 'ad']:
                verify_can_see(username, url)

        # RFC Editor Notes for documents in the IAB Stream
        draft.stream_id = 'iab'
        draft.save_with_history(events)
        url = urlreverse('ietf.doc.views_ballot.ballot_rfceditornote',
                         kwargs=dict(name=draft.name))

        for username in [
                'plain', 'marschairman', 'ad', 'irtf chair', 'ise', 'iana'
        ]:
            verify_fail(username, url)

        for username in ['secretary', 'iab chair']:
            verify_can_see(username, url)

        # RFC Editor Notes for documents in the IRTF Stream
        e = DocEvent(doc=draft,
                     rev=draft.rev,
                     by=Person.objects.get(name="(System)"),
                     type='changed_stream')
        e.desc = u"Changed stream to <b>%s</b>" % 'irtf'
        e.save()

        draft.stream_id = 'irtf'
        draft.save_with_history([e])
        url = urlreverse('ietf.doc.views_ballot.ballot_rfceditornote',
                         kwargs=dict(name=draft.name))

        for username in [
                'plain', 'marschairman', 'ad', 'iab chair', 'ise', 'iana'
        ]:
            verify_fail(username, url)

        for username in ['secretary', 'irtf chair']:
            verify_can_see(username, url)

        # RFC Editor Notes for documents in the IAB Stream
        e = DocEvent(doc=draft,
                     rev=draft.rev,
                     by=Person.objects.get(name="(System)"),
                     type='changed_stream')
        e.desc = u"Changed stream to <b>%s</b>" % 'ise'
        e.save()

        draft.stream_id = 'ise'
        draft.save_with_history([e])
        url = urlreverse('ietf.doc.views_ballot.ballot_rfceditornote',
                         kwargs=dict(name=draft.name))

        for username in [
                'plain', 'marschairman', 'ad', 'iab chair', 'irtf chair',
                'iana'
        ]:
            verify_fail(username, url)

        for username in ['secretary', 'ise']:
            verify_can_see(username, url)
示例#42
0
def ballot_writeupnotes(request, name):
    """Editing of ballot write-up and notes"""
    doc = get_object_or_404(Document, docalias__name=name)

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent, type="changed_ballot_writeup_text")
    if not existing:
        existing = generate_ballot_writeup(request, doc)
        
    form = BallotWriteupForm(initial=dict(ballot_writeup=existing.text))

    if request.method == 'POST' and "save_ballot_writeup" in request.POST or "issue_ballot" in request.POST:
        form = BallotWriteupForm(request.POST)
        if form.is_valid():
            t = form.cleaned_data["ballot_writeup"]
            if t != existing.text:
                e = WriteupDocEvent(doc=doc, by=login)
                e.by = login
                e.type = "changed_ballot_writeup_text"
                e.desc = "Ballot writeup was changed"
                e.text = t
                e.save()

            if "issue_ballot" in request.POST:
                create_ballot_if_not_open(doc, login, "approve")
                ballot = doc.latest_event(BallotDocEvent, type="created_ballot")

                if has_role(request.user, "Area Director") and not doc.latest_event(BallotPositionDocEvent, ad=login, ballot=ballot):
                    # sending the ballot counts as a yes
                    pos = BallotPositionDocEvent(doc=doc, by=login)
                    pos.ballot = ballot
                    pos.type = "changed_ballot_position"
                    pos.ad = login
                    pos.pos_id = "yes"
                    pos.desc = "[Ballot Position Update] New position, %s, has been recorded for %s" % (pos.pos.name, pos.ad.plain_name())
                    pos.save()

                approval = doc.latest_event(WriteupDocEvent, type="changed_ballot_approval_text")
                if not approval:
                    approval = generate_approval_mail(request, doc)

                msg = generate_issue_ballot_mail(request, doc, ballot)
                send_mail_preformatted(request, msg)
                send_mail_preformatted(request, msg, extra=extra_automation_headers(doc),
                                       override={ "To": "IANA <%s>"%settings.IANA_EVAL_EMAIL, "CC": None, "Bcc": None , "Reply-To": None})

                e = DocEvent(doc=doc, by=login)
                e.by = login
                e.type = "sent_ballot_announcement"
                e.desc = "Ballot has been issued"
                e.save()

                return render_to_response('doc/ballot/ballot_issued.html',
                                          dict(doc=doc,
                                               back_url=doc.get_absolute_url()),
                                          context_instance=RequestContext(request))
                        

    need_intended_status = ""
    if not doc.intended_std_level:
        need_intended_status = doc.file_tag()

    return render_to_response('doc/ballot/writeupnotes.html',
                              dict(doc=doc,
                                   back_url=doc.get_absolute_url(),
                                   ballot_issued=bool(doc.latest_event(type="sent_ballot_announcement")),
                                   ballot_writeup_form=form,
                                   need_intended_status=need_intended_status,
                                   ),
                              context_instance=RequestContext(request))
示例#43
0
def lastcalltext(request, name):
    """Editing of the last call text"""
    doc = get_object_or_404(Document, docalias__name=name)
    if not doc.get_state("draft-iesg"):
        raise Http404()

    login = request.user.person

    existing = doc.latest_event(WriteupDocEvent, type="changed_last_call_text")
    if not existing:
        existing = generate_last_call_announcement(request, doc)
        
    form = LastCallTextForm(initial=dict(last_call_text=existing.text))

    if request.method == 'POST':
        if "save_last_call_text" in request.POST or "send_last_call_request" in request.POST:
            form = LastCallTextForm(request.POST)
            if form.is_valid():
                t = form.cleaned_data['last_call_text']
                if t != existing.text:
                    e = WriteupDocEvent(doc=doc, by=login)
                    e.by = login
                    e.type = "changed_last_call_text"
                    e.desc = "Last call announcement was changed"
                    e.text = t
                    e.save()
                
                if "send_last_call_request" in request.POST:
                    save_document_in_history(doc)

                    prev_state = doc.get_state("draft-iesg")
                    new_state = State.objects.get(used=True, type="draft-iesg", slug='lc-req')

                    prev_tags = doc.tags.filter(slug__in=IESG_SUBSTATE_TAGS)

                    doc.set_state(new_state)
                    doc.tags.remove(*prev_tags)

                    e = add_state_change_event(doc, login, prev_state, new_state, prev_tags=prev_tags, new_tags=[])

                    doc.time = (e and e.time) or datetime.datetime.now()
                    doc.save()

                    email_state_changed(request, doc, e.desc)
                    email_ad(request, doc, doc.ad, login, e.desc)

                    request_last_call(request, doc)
                    
                    return render_to_response('doc/draft/last_call_requested.html',
                                              dict(doc=doc),
                                              context_instance=RequestContext(request))
        
        if "regenerate_last_call_text" in request.POST:
            e = generate_last_call_announcement(request, doc)
            
            # make sure form has the updated text
            form = LastCallTextForm(initial=dict(last_call_text=e.text))


    s = doc.get_state("draft-iesg")
    can_request_last_call = s.order < 27
    can_make_last_call = s.order < 20
    
    need_intended_status = ""
    if not doc.intended_std_level:
        need_intended_status = doc.file_tag()

    return render_to_response('doc/ballot/lastcalltext.html',
                              dict(doc=doc,
                                   back_url=doc.get_absolute_url(),
                                   last_call_form=form,
                                   can_request_last_call=can_request_last_call,
                                   can_make_last_call=can_make_last_call,
                                   need_intended_status=need_intended_status,
                                   ),
                              context_instance=RequestContext(request))