Skip to content

Commit cfb214c

Browse files
committed
Added a BallotCommentDocEvent, which extends DocEvent with a send_mail field, in order to better be able to show whether ballot discusses and comments were posted with with the 'send email' button or not.
- Legacy-Id: 15515
1 parent 194495d commit cfb214c

5 files changed

Lines changed: 63 additions & 10 deletions

File tree

ietf/doc/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
DocHistoryAuthor, DocHistory, DocAlias, DocReminder, DocEvent, NewRevisionDocEvent,
88
StateDocEvent, ConsensusDocEvent, BallotType, BallotDocEvent, WriteupDocEvent, LastCallDocEvent,
99
TelechatDocEvent, BallotPositionDocEvent, ReviewRequestDocEvent, InitialReviewDocEvent,
10+
BallotCommentDocEvent,
1011
AddedMessageEvent, SubmissionDocEvent, DeletedEvent, EditedAuthorsDocEvent, DocumentURL)
1112

1213

@@ -195,6 +196,7 @@ def short_desc(self, obj):
195196
admin.site.register(StateDocEvent, DocEventAdmin)
196197
admin.site.register(ConsensusDocEvent, DocEventAdmin)
197198
admin.site.register(BallotDocEvent, DocEventAdmin)
199+
admin.site.register(BallotCommentDocEvent, DocEventAdmin)
198200
admin.site.register(WriteupDocEvent, DocEventAdmin)
199201
admin.site.register(LastCallDocEvent, DocEventAdmin)
200202
admin.site.register(TelechatDocEvent, DocEventAdmin)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.15 on 2018-09-30 09:04
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('doc', '0005_fix_replaced_iab_irtf_stream_docs'),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='BallotCommentDocEvent',
18+
fields=[
19+
('docevent_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='doc.DocEvent')),
20+
('send_email', models.BooleanField(default=False)),
21+
],
22+
bases=('doc.docevent',),
23+
),
24+
]

ietf/doc/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,9 @@ class BallotPositionDocEvent(DocEvent):
11121112
comment = models.TextField(help_text="Optional comment", blank=True)
11131113
comment_time = models.DateTimeField(help_text="Time optional comment was written", blank=True, null=True)
11141114

1115+
class BallotCommentDocEvent(DocEvent):
1116+
send_email = models.BooleanField(default=False)
1117+
11151118
class WriteupDocEvent(DocEvent):
11161119
text = models.TextField(blank=True)
11171120

ietf/doc/resources.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
TelechatDocEvent, DocReminder, LastCallDocEvent, NewRevisionDocEvent, WriteupDocEvent,
1313
InitialReviewDocEvent, DocHistoryAuthor, BallotDocEvent, RelatedDocument,
1414
RelatedDocHistory, BallotPositionDocEvent, AddedMessageEvent, SubmissionDocEvent,
15-
ReviewRequestDocEvent, EditedAuthorsDocEvent, DocumentURL)
15+
ReviewRequestDocEvent, EditedAuthorsDocEvent, BallotCommentDocEvent, DocumentURL)
1616

1717
from ietf.name.resources import BallotPositionNameResource, DocTypeNameResource
1818
class BallotTypeResource(ModelResource):
@@ -648,3 +648,27 @@ class Meta:
648648
"tag": ALL_WITH_RELATIONS,
649649
}
650650
api.doc.register(DocumentURLResource())
651+
652+
653+
from ietf.person.resources import PersonResource
654+
class BallotCommentDocEventResource(ModelResource):
655+
by = ToOneField(PersonResource, 'by')
656+
doc = ToOneField(DocumentResource, 'doc')
657+
docevent_ptr = ToOneField(DocEventResource, 'docevent_ptr')
658+
class Meta:
659+
queryset = BallotCommentDocEvent.objects.all()
660+
serializer = api.Serializer()
661+
cache = SimpleCache()
662+
#resource_name = 'ballotcommentdocevent'
663+
filtering = {
664+
"id": ALL,
665+
"time": ALL,
666+
"type": ALL,
667+
"rev": ALL,
668+
"desc": ALL,
669+
"send_email": ALL,
670+
"by": ALL_WITH_RELATIONS,
671+
"doc": ALL_WITH_RELATIONS,
672+
"docevent_ptr": ALL_WITH_RELATIONS,
673+
}
674+
api.doc.register(BallotCommentDocEventResource())

ietf/doc/views_ballot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import debug # pyflakes:ignore
1717

1818
from ietf.doc.models import ( Document, State, DocEvent, BallotDocEvent, BallotPositionDocEvent,
19-
LastCallDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS )
19+
BallotCommentDocEvent, LastCallDocEvent, WriteupDocEvent, IESG_SUBSTATE_TAGS )
2020
from ietf.doc.utils import ( add_state_change_event, close_ballot, close_open_ballots,
2121
create_ballot_if_not_open, update_telechat )
2222
from ietf.doc.mails import ( email_ballot_deferred, email_ballot_undeferred,
@@ -112,7 +112,7 @@ def clean_discuss(self):
112112
raise forms.ValidationError("You must enter a non-empty discuss")
113113
return entered_discuss
114114

115-
def save_position(form, doc, ballot, ad, login=None):
115+
def save_position(form, doc, ballot, ad, login=None, send_email=False):
116116
# save the vote
117117
if login is None:
118118
login = ad
@@ -141,10 +141,10 @@ def save_position(form, doc, ballot, ad, login=None):
141141
changes.append("comment")
142142

143143
if pos.comment:
144-
e = DocEvent(doc=doc, rev=doc.rev)
145-
e.by = ad # otherwise we can't see who's saying it
144+
e = BallotCommentDocEvent(doc=doc, rev=doc.rev, by=ad, send_email=send_email)
146145
e.type = "added_comment"
147146
e.desc = "[Ballot comment]\n" + pos.comment
147+
148148
added_events.append(e)
149149

150150
old_discuss = old_pos.discuss if old_pos else ""
@@ -153,8 +153,7 @@ def save_position(form, doc, ballot, ad, login=None):
153153
changes.append("discuss")
154154

155155
if pos.pos.blocking:
156-
e = DocEvent(doc=doc, rev=doc.rev, by=login)
157-
e.by = ad # otherwise we can't see who's saying it
156+
e = BallotCommentDocEvent(doc=doc, rev=doc.rev, by=ad, send_email=send_email)
158157
e.type = "added_comment"
159158
e.desc = "[Ballot %s]\n" % pos.pos.name.lower()
160159
e.desc += pos.discuss
@@ -209,9 +208,10 @@ def edit_position(request, name, ballot_id):
209208

210209
form = EditPositionForm(request.POST, ballot_type=ballot.ballot_type)
211210
if form.is_valid():
212-
save_position(form, doc, ballot, ad, login)
211+
send_mail = request.POST.get("send_mail") or False
212+
save_position(form, doc, ballot, ad, login, send_mail)
213213

214-
if request.POST.get("send_mail"):
214+
if send_mail:
215215
qstr=""
216216
if request.GET.get('ad'):
217217
qstr += "?ad=%s" % request.GET.get('ad')
@@ -274,7 +274,7 @@ def err(code, text):
274274
return err(400, "No open ballot found")
275275
form = EditPositionForm(request.POST, ballot_type=ballot.ballot_type)
276276
if form.is_valid():
277-
pos = save_position(form, doc, ballot, ad)
277+
pos = save_position(form, doc, ballot, ad, send_email=True)
278278
else:
279279
errors = form.errors
280280
summary = ','.join([ "%s: %s" % (f, striptags(errors[f])) for f in errors ])

0 commit comments

Comments
 (0)