Esempio n. 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)
Esempio n. 2
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)
Esempio n. 3
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))
Esempio n. 4
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,
        ))