本文整理汇总了Python中ietf.doc.models.DocEvent.save方法的典型用法代码示例。如果您正苦于以下问题:Python DocEvent.save方法的具体用法?Python DocEvent.save怎么用?Python DocEvent.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ietf.doc.models.DocEvent
的用法示例。
在下文中一共展示了DocEvent.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assign_shepherd
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def assign_shepherd(user, internetdraft, shepherd):
if internetdraft.shepherd == shepherd:
return
from ietf.doc.models import save_document_in_history, DocEvent, Document
# saving the proxy object is a bit of a mess, so convert it to a
# proper document
doc = Document.objects.get(name=internetdraft.name)
save_document_in_history(doc)
doc.time = datetime.datetime.now()
doc.shepherd = shepherd
doc.save()
e = DocEvent(type="changed_document")
e.time = doc.time
e.doc = doc
e.by = user.get_profile()
if not shepherd:
e.desc = u"Unassigned shepherd"
else:
e.desc = u"Changed shepherd to %s" % shepherd.plain_name()
e.save()
# update proxy too
internetdraft.shepherd = shepherd
示例2: edit_ad
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_ad(request, name):
"""Change the responsible Area Director for this charter."""
charter = get_object_or_404(Document, type="charter", name=name)
login = request.user.person
if request.method == 'POST':
form = AdForm(request.POST)
if form.is_valid():
new_ad = form.cleaned_data['ad']
if new_ad != charter.ad:
save_document_in_history(charter)
e = DocEvent(doc=charter, by=login)
e.desc = "Responsible AD changed to %s" % new_ad.plain_name()
if charter.ad:
e.desc += " from %s" % charter.ad.plain_name()
e.type = "changed_document"
e.save()
charter.ad = new_ad
charter.time = e.time
charter.save()
return redirect('doc_view', name=charter.name)
else:
init = { "ad" : charter.ad_id }
form = AdForm(initial=init)
return render_to_response('doc/charter/change_ad.html',
{'form': form,
'charter': charter,
},
context_instance = RequestContext(request))
示例3: add_comment
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def add_comment(request, name):
"""Add comment to history of document."""
doc = get_object_or_404(Document, docalias__name=name)
login = request.user.person
if request.method == 'POST':
form = AddCommentForm(request.POST)
if form.is_valid():
c = form.cleaned_data['comment']
e = DocEvent(doc=doc, by=login)
e.type = "added_comment"
e.desc = c
e.save()
if doc.type_id == "draft":
email_ad(request, doc, doc.ad, login,
"A new comment added by %s" % login.name)
return redirect("doc_history", name=doc.name)
else:
form = AddCommentForm()
return render_to_response('doc/add_comment.html',
dict(doc=doc,
form=form),
context_instance=RequestContext(request))
示例4: edit_ad
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_ad(request, name):
"""Change the shepherding Area Director for this review."""
review = get_object_or_404(Document, type="conflrev", name=name)
if request.method == 'POST':
form = AdForm(request.POST)
if form.is_valid():
review.ad = form.cleaned_data['ad']
review.save()
login = request.user.person
c = DocEvent(type="added_comment", doc=review, by=login)
c.desc = "Shepherding AD changed to "+review.ad.name
c.save()
return redirect('doc_view', name=review.name)
else:
init = { "ad" : review.ad_id }
form = AdForm(initial=init)
conflictdoc = review.relateddocument_set.get(relationship__slug='conflrev').target.document
titletext = 'the conflict review of %s-%s' % (conflictdoc.canonical_name(),conflictdoc.rev)
return render_to_response('doc/change_ad.html',
{'form': form,
'doc': review,
'titletext': titletext
},
context_instance = RequestContext(request))
示例5: build_conflict_review_document
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def build_conflict_review_document(login, doc_to_review, ad, notify, create_in_state):
if doc_to_review.name.startswith('draft-'):
review_name = 'conflict-review-'+doc_to_review.name[6:]
else:
# This is a failsafe - and might be treated better as an error
review_name = 'conflict-review-'+doc_to_review.name
iesg_group = Group.objects.get(acronym='iesg')
conflict_review=Document( type_id = "conflrev",
title = "IETF conflict review for %s" % doc_to_review.name,
name = review_name,
rev = "00",
ad = ad,
notify = notify,
stream_id = 'ietf',
group = iesg_group,
)
conflict_review.save()
conflict_review.set_state(create_in_state)
DocAlias.objects.create( name=review_name , document=conflict_review )
conflict_review.relateddocument_set.create(target=DocAlias.objects.get(name=doc_to_review.name),relationship_id='conflrev')
c = DocEvent(type="added_comment", doc=conflict_review, by=login)
c.desc = "IETF conflict review requested"
c.save()
c = DocEvent(type="added_comment", doc=doc_to_review, by=login)
# Is it really OK to put html tags into comment text?
c.desc = 'IETF conflict review initiated - see <a href="%s">%s</a>' % (reverse('doc_view', kwargs={'name':conflict_review.name}),conflict_review.name)
c.save()
return conflict_review
示例6: edit_title
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_title(request, name):
"""Change the title for this status_change document."""
status_change = get_object_or_404(Document, type="statchg", name=name)
if request.method == 'POST':
form = ChangeTitleForm(request.POST)
if form.is_valid():
status_change.title = form.cleaned_data['title']
status_change.save()
login = request.user.person
c = DocEvent(type="added_comment", doc=status_change, by=login)
c.desc = "Title changed to '%s'"%status_change.title
c.save()
return redirect("doc_view", name=status_change.name)
else:
init = { "title" : status_change.title }
form = ChangeTitleForm(initial=init)
titletext = '%s-%s.txt' % (status_change.canonical_name(),status_change.rev)
return render_to_response('doc/change_title.html',
{'form': form,
'doc': status_change,
'titletext' : titletext,
},
context_instance = RequestContext(request))
示例7: edit_notices
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_notices(request, name):
"""Change the set of email addresses document change notificaitions go to."""
status_change = get_object_or_404(Document, type="statchg", name=name)
if request.method == 'POST':
form = NotifyForm(request.POST)
if form.is_valid():
status_change.notify = form.cleaned_data['notify']
status_change.save()
login = request.user.get_profile()
c = DocEvent(type="added_comment", doc=status_change, by=login)
c.desc = "Notification list changed to : "+status_change.notify
c.save()
return HttpResponseRedirect(reverse('doc_view', kwargs={'name': status_change.name}))
else:
init = { "notify" : status_change.notify }
form = NotifyForm(initial=init)
return render_to_response('doc/notify.html',
{'form': form,
'doc': status_change,
'titletext' : '%s-%s.txt' % (status_change.canonical_name(),status_change.rev)
},
context_instance = RequestContext(request))
示例8: expire_draft
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def expire_draft(doc):
# clean up files
move_draft_files_to_archive(doc, doc.rev)
system = Person.objects.get(name="(System)")
# change the state
save_document_in_history(doc)
if doc.latest_event(type='started_iesg_process'):
new_state = State.objects.get(used=True, type="draft-iesg", slug="dead")
prev_state = doc.get_state(new_state.type_id)
prev_tags = doc.tags.filter(slug__in=IESG_SUBSTATE_TAGS)
if new_state != prev_state:
doc.set_state(new_state)
doc.tags.remove(*prev_tags)
e = add_state_change_event(doc, system, prev_state, new_state, prev_tags=prev_tags, new_tags=[])
e = DocEvent(doc=doc, by=system)
e.type = "expired_document"
e.desc = "Document has expired"
e.save()
doc.set_state(State.objects.get(used=True, type="draft", slug="expired"))
doc.time = datetime.datetime.now()
doc.save()
示例9: edit_notify
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_notify(request, name):
doc = get_object_or_404(Document, type="charter", name=name)
login = request.user.person
init = {'notify': doc.notify}
if request.method == "POST":
form = NotifyForm(request.POST, initial=init)
if form.is_valid():
n = form.cleaned_data["notify"]
if n != doc.notify:
save_document_in_history(doc)
e = DocEvent(doc=doc, by=login)
e.desc = "Notification list changed to %s" % (escape(n) or "none")
if doc.notify:
e.desc += " from %s" % escape(doc.notify)
e.type = "changed_document"
e.save()
doc.notify = n
doc.time = e.time
doc.save()
return redirect("doc_view", name=doc.name)
else:
form = NotifyForm(initial=init)
return render_to_response('doc/charter/edit_notify.html',
dict(doc=doc,
form=form,
user=request.user,
login=login),
context_instance=RequestContext(request))
示例10: change_state
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def change_state(request, name, option=None):
"""Change state of an IESG review for IETF conflicts in other stream's documents, notifying parties as necessary
and logging the change as a comment."""
review = get_object_or_404(Document, type="conflrev", name=name)
login = request.user.get_profile()
if request.method == 'POST':
form = ChangeStateForm(request.POST)
if form.is_valid():
clean = form.cleaned_data
review_state = clean['review_state']
comment = clean['comment'].rstrip()
if comment:
c = DocEvent(type="added_comment", doc=review, by=login)
c.desc = comment
c.save()
if review_state != review.get_state():
save_document_in_history(review)
old_description = review.friendly_state()
review.set_state(review_state)
new_description = review.friendly_state()
log_state_changed(request, review, login, new_description, old_description)
review.time = datetime.datetime.now()
review.save()
if review_state.slug == "iesgeval":
create_ballot_if_not_open(review, login, "conflrev")
ballot = review.latest_event(BallotDocEvent, type="created_ballot")
if has_role(request.user, "Area Director") and not review.latest_event(BallotPositionDocEvent, ad=login, ballot=ballot, type="changed_ballot_position"):
# The AD putting a conflict review into iesgeval who doesn't already have a position is saying "yes"
pos = BallotPositionDocEvent(doc=review, 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()
send_conflict_eval_email(request,review)
return redirect('doc_view', name=review.name)
else:
s = review.get_state()
init = dict(review_state=s.pk if s else None)
form = ChangeStateForm(initial=init)
return render_to_response('doc/change_state.html',
dict(form=form,
doc=review,
login=login,
help_url=reverse('help_conflict_review_states'),
),
context_instance=RequestContext(request))
示例11: edit_ad
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_ad(request, name):
"""Change the shepherding Area Director for this status_change."""
status_change = get_object_or_404(Document, type="statchg", name=name)
if request.method == 'POST':
form = AdForm(request.POST)
if form.is_valid():
status_change.ad = form.cleaned_data['ad']
status_change.save()
login = request.user.get_profile()
c = DocEvent(type="added_comment", doc=status_change, by=login)
c.desc = "Shepherding AD changed to "+status_change.ad.name
c.save()
return redirect("doc_view", name=status_change.name)
else:
init = { "ad" : status_change.ad_id }
form = AdForm(initial=init)
titletext = '%s-%s.txt' % (status_change.canonical_name(),status_change.rev)
return render_to_response('doc/change_ad.html',
{'form': form,
'doc': status_change,
'titletext' : titletext,
},
context_instance = RequestContext(request))
示例12: edit_notices
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def edit_notices(request, name):
"""Change the set of email addresses document change notificaitions go to."""
review = get_object_or_404(Document, type="conflrev", name=name)
if request.method == 'POST':
form = NotifyForm(request.POST)
if form.is_valid():
review.notify = form.cleaned_data['notify']
review.save()
login = request.user.person
c = DocEvent(type="added_comment", doc=review, by=login)
c.desc = "Notification list changed to : "+review.notify
c.save()
return redirect('doc_view', name=review.name)
else:
init = { "notify" : review.notify }
form = NotifyForm(initial=init)
conflictdoc = review.relateddocument_set.get(relationship__slug='conflrev').target.document
titletext = 'the conflict review of %s-%s' % (conflictdoc.canonical_name(),conflictdoc.rev)
return render_to_response('doc/notify.html',
{'form': form,
'doc': review,
'titletext' : titletext
},
context_instance = RequestContext(request))
示例13: log_state_changed
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def log_state_changed(request, doc, by, prev_state):
e = DocEvent(doc=doc, by=by)
e.type = "changed_document"
e.desc = u"State changed to <b>%s</b> from %s" % (
doc.get_state().name,
prev_state.name if prev_state else "None")
e.save()
return e
示例14: update_tags
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def update_tags(request, obj, comment, person, set_tags=[], reset_tags=[], extra_notify=[]):
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
doc = Document.objects.get(pk=obj.pk)
save_document_in_history(doc)
obj.tags.remove(*reset_tags)
obj.tags.add(*set_tags)
doc.time = datetime.datetime.now()
e = DocEvent(type="changed_document", time=doc.time, by=person, doc=doc)
l = []
if set_tags:
l.append(u"Annotation tag%s %s set." % (pluralize(set_tags), ", ".join(x.name for x in set_tags)))
if reset_tags:
l.append(u"Annotation tag%s %s cleared." % (pluralize(reset_tags), ", ".join(x.name for x in reset_tags)))
e.desc = " ".join(l)
e.save()
receivers = get_notification_receivers(doc, extra_notify)
send_mail(request, receivers, settings.DEFAULT_FROM_EMAIL,
u"Annotations tags changed for draft %s" % doc.name,
'ietfworkflows/annotation_tags_updated_mail.txt',
dict(doc=doc,
entry=dict(setted=", ".join(x.name for x in set_tags),
unsetted=", ".join(x.name for x in reset_tags),
change_date=doc.time,
person=person,
comment=comment)))
return
ctype = ContentType.objects.get_for_model(obj)
setted = []
resetted = []
for tag in set_tags:
if isinstance(tag, basestring):
if set_tag_by_name(obj, tag):
setted.append(tag)
else:
if set_tag(obj, tag):
setted.append(tag.name)
for tag in reset_tags:
if isinstance(tag, basestring):
if reset_tag_by_name(obj, tag):
resetted.append(tag)
else:
if reset_tag(obj, tag):
resetted.append(tag.name)
entry = ObjectAnnotationTagHistoryEntry.objects.create(
content_type=ctype,
content_id=obj.pk,
setted=','.join(setted),
unsetted=','.join(resetted),
date=datetime.datetime.now(),
comment=comment,
person=person)
notify_tag_entry(entry, extra_notify)
示例15: approve
# 需要导入模块: from ietf.doc.models import DocEvent [as 别名]
# 或者: from ietf.doc.models.DocEvent import save [as 别名]
def approve(request, name):
"""Approve this conflict review, setting the appropriate state and send the announcement to the right parties."""
review = get_object_or_404(Document, type="conflrev", name=name)
if review.get_state('conflrev').slug not in ('appr-reqnopub-pend','appr-noprob-pend'):
raise Http404
login = request.user.get_profile()
if request.method == 'POST':
form = AnnouncementForm(request.POST)
if form.is_valid():
new_state_slug = 'appr-reqnopub-sent' if review.get_state('conflrev').slug=='appr-reqnopub-pend' else 'appr-noprob-sent'
new_review_state = State.objects.get(used=True, type="conflrev", slug=new_state_slug)
save_document_in_history(review)
old_description = review.friendly_state()
review.set_state(new_review_state)
new_description = review.friendly_state()
log_state_changed(request, review, login, new_description, old_description)
close_open_ballots(review, login)
e = DocEvent(doc=review, by=login)
e.type = "iesg_approved"
e.desc = "IESG has approved the conflict review response"
e.save()
review.time = e.time
review.save()
# send announcement
send_mail_preformatted(request, form.cleaned_data['announcement_text'])
c = DocEvent(type="added_comment", doc=review, by=login)
c.desc = "The following approval message was sent\n"+form.cleaned_data['announcement_text']
c.save()
return HttpResponseRedirect(review.get_absolute_url())
else:
init = { "announcement_text" : default_approval_text(review) }
form = AnnouncementForm(initial=init)
return render_to_response('doc/conflict_review/approve.html',
dict(
review = review,
conflictdoc = review.relateddocument_set.get(relationship__slug='conflrev').target.document,
form = form,
),
context_instance=RequestContext(request))