Remove shim layer from submit code
- Legacy-Id: 6654
This commit is contained in:
parent
e1708da2fe
commit
2daff23f02
|
@ -14,11 +14,11 @@ from django.core.urlresolvers import reverse as urlreverse
|
|||
|
||||
import debug
|
||||
|
||||
from ietf.group.models import Group
|
||||
from ietf.idtracker.models import InternetDraft, IETFWG
|
||||
from ietf.proceedings.models import Meeting
|
||||
from ietf.group.models import Group, Role
|
||||
from ietf.doc.models import Document
|
||||
from ietf.meeting.models import Meeting
|
||||
from ietf.submit.models import IdSubmissionDetail, TempIdAuthors, Preapproval
|
||||
from ietf.submit.utils import MANUAL_POST_REQUESTED, NONE_WG, UPLOADED, AWAITING_AUTHENTICATION, POSTED, POSTED_BY_SECRETARIAT
|
||||
from ietf.submit.utils import MANUAL_POST_REQUESTED, UPLOADED, AWAITING_AUTHENTICATION, POSTED, POSTED_BY_SECRETARIAT, submission_confirmation_email_list
|
||||
from ietf.submit.parsers.pdf_parser import PDFParser
|
||||
from ietf.submit.parsers.plain_parser import PlainParser
|
||||
from ietf.submit.parsers.ps_parser import PSParser
|
||||
|
@ -154,14 +154,14 @@ class UploadForm(forms.Form):
|
|||
same_name = IdSubmissionDetail.objects.filter(filename=filename, revision=revision, submission_date=today)
|
||||
if same_name.count() > settings.MAX_SAME_DRAFT_NAME:
|
||||
raise forms.ValidationError('The same I-D cannot be submitted more than %s times a day' % settings.MAX_SAME_DRAFT_NAME)
|
||||
if sum([i.filesize for i in same_name]) > (settings.MAX_SAME_DRAFT_NAME_SIZE * 1048576):
|
||||
if sum(i.filesize for i in same_name) > settings.MAX_SAME_DRAFT_NAME_SIZE * 1048576:
|
||||
raise forms.ValidationError('The same I-D submission cannot exceed more than %s MByte a day' % settings.MAX_SAME_DRAFT_NAME_SIZE)
|
||||
|
||||
# Total from same ip
|
||||
same_ip = IdSubmissionDetail.objects.filter(remote_ip=remote_ip, submission_date=today)
|
||||
if same_ip.count() > settings.MAX_SAME_SUBMITTER:
|
||||
raise forms.ValidationError('The same submitter cannot submit more than %s I-Ds a day' % settings.MAX_SAME_SUBMITTER)
|
||||
if sum([i.filesize for i in same_ip]) > (settings.MAX_SAME_SUBMITTER_SIZE * 1048576):
|
||||
if sum(i.filesize for i in same_ip) > settings.MAX_SAME_SUBMITTER_SIZE * 1048576:
|
||||
raise forms.ValidationError('The same submitter cannot exceed more than %s MByte a day' % settings.MAX_SAME_SUBMITTER_SIZE)
|
||||
|
||||
# Total in same group
|
||||
|
@ -169,7 +169,7 @@ class UploadForm(forms.Form):
|
|||
same_group = IdSubmissionDetail.objects.filter(group_acronym=self.group, submission_date=today)
|
||||
if same_group.count() > settings.MAX_SAME_WG_DRAFT:
|
||||
raise forms.ValidationError('The same working group I-Ds cannot be submitted more than %s times a day' % settings.MAX_SAME_WG_DRAFT)
|
||||
if sum([i.filesize for i in same_group]) > (settings.MAX_SAME_WG_DRAFT_SIZE * 1048576):
|
||||
if sum(i.filesize for i in same_group) > settings.MAX_SAME_WG_DRAFT_SIZE * 1048576:
|
||||
raise forms.ValidationError('Total size of same working group I-Ds cannot exceed %s MByte a day' % settings.MAX_SAME_WG_DRAFT_SIZE)
|
||||
|
||||
|
||||
|
@ -177,7 +177,7 @@ class UploadForm(forms.Form):
|
|||
total_today = IdSubmissionDetail.objects.filter(submission_date=today)
|
||||
if total_today.count() > settings.MAX_DAILY_SUBMISSION:
|
||||
raise forms.ValidationError('The total number of today\'s submission has reached the maximum number of submission per day')
|
||||
if sum([i.filesize for i in total_today]) > (settings.MAX_DAILY_SUBMISSION_SIZE * 1048576):
|
||||
if sum(i.filesize for i in total_today) > settings.MAX_DAILY_SUBMISSION_SIZE * 1048576:
|
||||
raise forms.ValidationError('The total size of today\'s submission has reached the maximum size of submission per day')
|
||||
|
||||
def check_paths(self):
|
||||
|
@ -234,10 +234,10 @@ class UploadForm(forms.Form):
|
|||
|
||||
def get_working_group(self):
|
||||
name = self.draft.filename
|
||||
existing_draft = InternetDraft.objects.filter(filename=name)
|
||||
existing_draft = Document.objects.filter(name=name, type="draft")
|
||||
if existing_draft:
|
||||
group = existing_draft[0].group and existing_draft[0].group.ietfwg or None
|
||||
if group and group.pk != NONE_WG and group.type_id != "area":
|
||||
group = existing_draft[0].group
|
||||
if group and group.type_id not in ("individ", "area"):
|
||||
return group
|
||||
else:
|
||||
return None
|
||||
|
@ -255,25 +255,18 @@ class UploadForm(forms.Form):
|
|||
# first check groups with dashes
|
||||
for g in Group.objects.filter(acronym__contains="-", type=group_type):
|
||||
if name.startswith('draft-%s-%s-' % (components[1], g.acronym)):
|
||||
return IETFWG().from_object(g)
|
||||
return g
|
||||
|
||||
try:
|
||||
return IETFWG().from_object(Group.objects.get(acronym=components[2], type=group_type))
|
||||
return Group.objects.get(acronym=components[2], type=group_type)
|
||||
except Group.DoesNotExist:
|
||||
raise forms.ValidationError('There is no active group with acronym \'%s\', please rename your draft' % components[2])
|
||||
elif name.startswith("draft-iab-"):
|
||||
return IETFWG().from_object(Group.objects.get(acronym="iab"))
|
||||
return Group.objects.get(acronym="iab")
|
||||
else:
|
||||
return None
|
||||
|
||||
def save_draft_info(self, draft):
|
||||
document_id = 0
|
||||
existing_draft = InternetDraft.objects.filter(filename=draft.filename)
|
||||
if existing_draft:
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
document_id = -1
|
||||
else:
|
||||
document_id = existing_draft[0].id_document_tag
|
||||
detail = IdSubmissionDetail.objects.create(
|
||||
id_document_name=draft.get_title(),
|
||||
filename=draft.filename,
|
||||
|
@ -283,7 +276,7 @@ class UploadForm(forms.Form):
|
|||
creation_date=draft.get_creation_date(),
|
||||
submission_date=datetime.date.today(),
|
||||
idnits_message=self.idnits_message,
|
||||
temp_id_document_tag=document_id,
|
||||
temp_id_document_tag=-1,
|
||||
group_acronym=self.group,
|
||||
remote_ip=self.remote_ip,
|
||||
first_two_pages=''.join(draft.pages[:2]),
|
||||
|
@ -291,38 +284,21 @@ class UploadForm(forms.Form):
|
|||
abstract=draft.get_abstract(),
|
||||
file_type=','.join(self.file_type),
|
||||
)
|
||||
order = 0
|
||||
for author in draft.get_author_list():
|
||||
for order, author in enumerate(draft.get_author_list(), start=1):
|
||||
full_name, first_name, middle_initial, last_name, name_suffix, email, company = author
|
||||
order += 1
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
# save full name
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=document_id,
|
||||
first_name=full_name.strip(),
|
||||
email_address=(email or "").strip(),
|
||||
author_order=order,
|
||||
submission=detail)
|
||||
else:
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=document_id,
|
||||
first_name=first_name,
|
||||
middle_initial=middle_initial,
|
||||
last_name=last_name,
|
||||
name_suffix=name_suffix,
|
||||
email_address=email,
|
||||
author_order=order,
|
||||
submission=detail)
|
||||
# save full name
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=-1,
|
||||
first_name=full_name.strip(),
|
||||
email_address=(email or "").strip(),
|
||||
author_order=order,
|
||||
submission=detail)
|
||||
return detail
|
||||
|
||||
|
||||
class AutoPostForm(forms.Form):
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
name = forms.CharField(required=True)
|
||||
else:
|
||||
first_name = forms.CharField(label=u'Given name', required=True)
|
||||
last_name = forms.CharField(label=u'Last name', required=True)
|
||||
name = forms.CharField(required=True)
|
||||
email = forms.EmailField(label=u'Email address', required=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -332,26 +308,12 @@ class AutoPostForm(forms.Form):
|
|||
super(AutoPostForm, self).__init__(*args, **kwargs)
|
||||
|
||||
def get_author_buttons(self):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
buttons = []
|
||||
for i in self.validation.authors:
|
||||
buttons.append('<input type="button" data-name="%(name)s" data-email="%(email)s" value="%(name)s" />'
|
||||
% dict(name=i.get_full_name(),
|
||||
email=i.email()[1] or ''))
|
||||
return "".join(buttons)
|
||||
|
||||
|
||||
# this should be moved to a Javascript file and attributes like data-first-name ...
|
||||
button_template = '<input type="button" onclick="jQuery(\'#id_first_name\').val(\'%(first_name)s\');jQuery(\'#id_last_name\').val(\'%(last_name)s\');jQuery(\'#id_email\').val(\'%(email)s\');" value="%(full_name)s" />'
|
||||
|
||||
buttons = []
|
||||
for i in self.validation.authors:
|
||||
full_name = u'%s. %s' % (i.first_name[0], i.last_name)
|
||||
buttons.append(button_template % {'first_name': i.first_name,
|
||||
'last_name': i.last_name,
|
||||
'email': i.email()[1] or '',
|
||||
'full_name': full_name})
|
||||
return ''.join(buttons)
|
||||
buttons.append('<input type="button" data-name="%(name)s" data-email="%(email)s" value="%(name)s" />'
|
||||
% dict(name=i.get_full_name(),
|
||||
email=i.email()[1] or ''))
|
||||
return "".join(buttons)
|
||||
|
||||
def save(self, request):
|
||||
self.save_submitter_info()
|
||||
|
@ -361,7 +323,7 @@ class AutoPostForm(forms.Form):
|
|||
def send_confirmation_mail(self, request):
|
||||
subject = 'Confirmation for Auto-Post of I-D %s' % self.draft.filename
|
||||
from_email = settings.IDSUBMIT_FROM_EMAIL
|
||||
to_email = self.draft.confirmation_email_list()
|
||||
to_email = submission_confirmation_email_list(self.draft)
|
||||
|
||||
confirm_url = settings.IDTRACKER_BASE_URL + urlreverse('draft_confirm', kwargs=dict(submission_id=self.draft.submission_id, auth_key=self.draft.auth_key))
|
||||
status_url = settings.IDTRACKER_BASE_URL + urlreverse('draft_status_by_hash', kwargs=dict(submission_id=self.draft.submission_id, submission_hash=self.draft.get_hash()))
|
||||
|
@ -370,21 +332,13 @@ class AutoPostForm(forms.Form):
|
|||
{ 'draft': self.draft, 'confirm_url': confirm_url, 'status_url': status_url })
|
||||
|
||||
def save_submitter_info(self):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
return TempIdAuthors.objects.create(
|
||||
id_document_tag=self.draft.temp_id_document_tag,
|
||||
first_name=self.cleaned_data['name'],
|
||||
email_address=self.cleaned_data['email'],
|
||||
author_order=0,
|
||||
submission=self.draft)
|
||||
|
||||
return TempIdAuthors.objects.create(
|
||||
id_document_tag=self.draft.temp_id_document_tag,
|
||||
first_name=self.cleaned_data['first_name'],
|
||||
last_name=self.cleaned_data['last_name'],
|
||||
first_name=self.cleaned_data['name'],
|
||||
email_address=self.cleaned_data['email'],
|
||||
author_order=0,
|
||||
submission=self.draft)
|
||||
submission=self.draft,
|
||||
)
|
||||
|
||||
def save_new_draft_info(self):
|
||||
salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
|
||||
|
@ -400,18 +354,11 @@ class MetaDataForm(AutoPostForm):
|
|||
creation_date = forms.DateField(label=u'Creation date', required=True)
|
||||
pages = forms.IntegerField(label=u'Pages', required=True)
|
||||
abstract = forms.CharField(label=u'Abstract', widget=forms.Textarea, required=True)
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
name = forms.CharField(required=True)
|
||||
else:
|
||||
first_name = forms.CharField(label=u'Given name', required=True)
|
||||
last_name = forms.CharField(label=u'Last name', required=True)
|
||||
name = forms.CharField(required=True)
|
||||
email = forms.EmailField(label=u'Email address', required=True)
|
||||
comments = forms.CharField(label=u'Comments to the secretariat', widget=forms.Textarea, required=False)
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
fields = ['title', 'version', 'creation_date', 'pages', 'abstract', 'name', 'email', 'comments']
|
||||
else:
|
||||
fields = ['title', 'version', 'creation_date', 'pages', 'abstract', 'first_name', 'last_name', 'email', 'comments']
|
||||
fields = ['title', 'version', 'creation_date', 'pages', 'abstract', 'name', 'email', 'comments']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MetaDataForm, self).__init__(*args, **kwargs)
|
||||
|
@ -422,43 +369,21 @@ class MetaDataForm(AutoPostForm):
|
|||
authors=[]
|
||||
if self.is_bound:
|
||||
for key, value in self.data.items():
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
if key.startswith('name_'):
|
||||
author = {'errors': {}}
|
||||
index = key.replace('name_', '')
|
||||
name = value.strip()
|
||||
if not name:
|
||||
author['errors']['name'] = 'This field is required'
|
||||
email = self.data.get('email_%s' % index, '').strip()
|
||||
if email and not email_re.search(email):
|
||||
author['errors']['email'] = 'Enter a valid e-mail address'
|
||||
if name or email:
|
||||
author.update({'get_full_name': name,
|
||||
'email': (name, email),
|
||||
'index': index,
|
||||
})
|
||||
authors.append(author)
|
||||
|
||||
else:
|
||||
if key.startswith('first_name_'):
|
||||
author = {'errors': {}}
|
||||
index = key.replace('first_name_', '')
|
||||
first_name = value.strip()
|
||||
if not first_name:
|
||||
author['errors']['first_name'] = 'This field is required'
|
||||
last_name = self.data.get('last_name_%s' % index, '').strip()
|
||||
if not last_name:
|
||||
author['errors']['last_name'] = 'This field is required'
|
||||
email = self.data.get('email_%s' % index, '').strip()
|
||||
if email and not email_re.search(email):
|
||||
author['errors']['email'] = 'Enter a valid e-mail address'
|
||||
if first_name or last_name or email:
|
||||
author.update({'first_name': first_name,
|
||||
'last_name': last_name,
|
||||
'email': ('%s %s' % (first_name, last_name), email),
|
||||
'index': index,
|
||||
})
|
||||
authors.append(author)
|
||||
if key.startswith('name_'):
|
||||
author = {'errors': {}}
|
||||
index = key.replace('name_', '')
|
||||
name = value.strip()
|
||||
if not name:
|
||||
author['errors']['name'] = 'This field is required'
|
||||
email = self.data.get('email_%s' % index, '').strip()
|
||||
if email and not email_re.search(email):
|
||||
author['errors']['email'] = 'Enter a valid e-mail address'
|
||||
if name or email:
|
||||
author.update({'get_full_name': name,
|
||||
'email': (name, email),
|
||||
'index': index,
|
||||
})
|
||||
authors.append(author)
|
||||
authors.sort(key=lambda x: x['index'])
|
||||
return authors
|
||||
|
||||
|
@ -491,7 +416,7 @@ class MetaDataForm(AutoPostForm):
|
|||
raise forms.ValidationError('Version field is not in NN format')
|
||||
if version_int > 99 or version_int < 0:
|
||||
raise forms.ValidationError('Version must be set between 00 and 99')
|
||||
existing_revisions = [int(i.revision_display()) for i in InternetDraft.objects.filter(filename=self.draft.filename)]
|
||||
existing_revisions = [int(i.rev) for i in Document.objects.filter(name=self.draft.filename)]
|
||||
expected = 0
|
||||
if existing_revisions:
|
||||
expected = max(existing_revisions) + 1
|
||||
|
@ -536,14 +461,12 @@ class MetaDataForm(AutoPostForm):
|
|||
self.save_submitter_info() # submitter is author 0
|
||||
|
||||
for i, author in enumerate(self.authors):
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
# save full name
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=draft.temp_id_document_tag,
|
||||
first_name=author["get_full_name"],
|
||||
email_address=author["email"][1],
|
||||
author_order=i + 1,
|
||||
submission=draft)
|
||||
TempIdAuthors.objects.create(
|
||||
id_document_tag=draft.temp_id_document_tag,
|
||||
first_name=author["get_full_name"], # save full name
|
||||
email_address=author["email"][1],
|
||||
author_order=i + 1,
|
||||
submission=draft)
|
||||
|
||||
def save(self, request):
|
||||
self.save_new_draft_info()
|
||||
|
@ -556,7 +479,7 @@ class MetaDataForm(AutoPostForm):
|
|||
cc = [self.cleaned_data['email']]
|
||||
cc += [i['email'][1] for i in self.authors]
|
||||
if self.draft.group_acronym:
|
||||
cc += [i.person.email()[1] for i in self.draft.group_acronym.wgchair_set.all()]
|
||||
cc += [r.email.address for r in Role.objects.filter(group=self.draft.group_acronym, name="chair").select_related("email")]
|
||||
cc = list(set(cc))
|
||||
submitter = self.draft.tempidauthors_set.get(author_order=0)
|
||||
send_mail(request, to_email, from_email, subject, 'submit/manual_post_mail.txt', {
|
||||
|
@ -588,7 +511,7 @@ class PreapprovalForm(forms.Form):
|
|||
raise forms.ValidationError("Name ends with a dash.")
|
||||
acronym = components[2]
|
||||
if acronym not in self.groups.values_list('acronym', flat=True):
|
||||
raise forms.ValidationError("WG acronym not recognized as one you can approve drafts for.")
|
||||
raise forms.ValidationError("Group acronym not recognized as one you can approve drafts for.")
|
||||
|
||||
if Preapproval.objects.filter(name=n):
|
||||
raise forms.ValidationError("Pre-approval for this name already exists.")
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import re, datetime #
|
||||
import re, datetime, hashlib
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.hashcompat import md5_constructor
|
||||
|
||||
from ietf.idtracker.models import InternetDraft, IETFWG
|
||||
from ietf.person.models import Person
|
||||
from ietf.group.models import Group
|
||||
|
||||
|
||||
class IdSubmissionStatus(models.Model):
|
||||
|
@ -22,7 +21,7 @@ class IdSubmissionDetail(models.Model):
|
|||
last_updated_date = models.DateField(null=True, blank=True)
|
||||
last_updated_time = models.CharField(null=True, blank=True, max_length=25)
|
||||
id_document_name = models.CharField(null=True, blank=True, max_length=255)
|
||||
group_acronym = models.ForeignKey(IETFWG, null=True, blank=True)
|
||||
group_acronym = models.ForeignKey(Group, null=True, blank=True)
|
||||
filename = models.CharField(null=True, blank=True, max_length=255, db_index=True)
|
||||
creation_date = models.DateField(null=True, blank=True)
|
||||
submission_date = models.DateField(null=True, blank=True)
|
||||
|
@ -51,7 +50,7 @@ class IdSubmissionDetail(models.Model):
|
|||
return u"%s-%s" % (self.filename, self.revision)
|
||||
|
||||
def create_hash(self):
|
||||
self.submission_hash = md5_constructor(settings.SECRET_KEY + self.filename).hexdigest()
|
||||
self.submission_hash = hashlib.md5(settings.SECRET_KEY + self.filename).hexdigest()
|
||||
|
||||
def get_hash(self):
|
||||
if not self.submission_hash:
|
||||
|
@ -68,14 +67,6 @@ class IdSubmissionDetail(models.Model):
|
|||
return '<a href="http://datatracker.ietf.org/submit/status/%s/%s/">%s</a>' % (self.submission_id, self.submission_hash, self.status)
|
||||
status_link.allow_tags = True
|
||||
|
||||
def confirmation_email_list(self):
|
||||
try:
|
||||
draft = InternetDraft.objects.get(filename=self.filename)
|
||||
email_list = list(set(u'%s <%s>' % (i.person.ascii, i.email()) for i in draft.authors))
|
||||
except InternetDraft.DoesNotExist:
|
||||
email_list = list(set(u'%s <%s>' % i.email() for i in self.tempidauthors_set.all()))
|
||||
return email_list
|
||||
|
||||
def create_submission_hash(sender, instance, **kwargs):
|
||||
instance.create_hash()
|
||||
|
||||
|
@ -102,10 +93,6 @@ class TempIdAuthors(models.Model):
|
|||
middle_initial = models.CharField(blank=True, max_length=255, null=True)
|
||||
name_suffix = models.CharField(blank=True, max_length=255, null=True)
|
||||
|
||||
class Meta:
|
||||
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
db_table = 'temp_id_authors'
|
||||
|
||||
def email(self):
|
||||
return (self.get_full_name(), self.email_address)
|
||||
|
||||
|
|
|
@ -2,12 +2,9 @@ import datetime
|
|||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from ietf.idtracker.models import InternetDraft, IETFWG
|
||||
from django.template.defaultfilters import filesizeformat
|
||||
from ietf.submit.parsers.base import FileParser
|
||||
|
||||
NONE_WG_PK = 1027
|
||||
|
||||
|
||||
class PlainParser(FileParser):
|
||||
|
||||
|
|
|
@ -7,14 +7,12 @@ from django.contrib.sites.models import Site
|
|||
from django.core.urlresolvers import reverse as urlreverse
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from ietf.idtracker.models import (InternetDraft, PersonOrOrgInfo, IETFWG,
|
||||
IDAuthor, EmailAddress, IESGLogin, BallotInfo)
|
||||
from ietf.submit.models import TempIdAuthors, IdSubmissionDetail, Preapproval
|
||||
from ietf.utils.mail import send_mail, send_mail_message
|
||||
from ietf.utils.log import log
|
||||
from ietf.utils import unaccent
|
||||
from ietf.ietfauth.decorators import has_role
|
||||
from ietf.ietfauth.utils import has_role
|
||||
|
||||
from ietf.submit.models import TempIdAuthors, IdSubmissionDetail, Preapproval
|
||||
from ietf.doc.models import *
|
||||
from ietf.person.models import Person, Alias, Email
|
||||
from ietf.doc.utils import add_state_change_event
|
||||
|
@ -30,14 +28,11 @@ CANCELLED = -4
|
|||
INITIAL_VERSION_APPROVAL_REQUESTED = 10
|
||||
|
||||
|
||||
# Not a real WG
|
||||
NONE_WG = 1027
|
||||
|
||||
|
||||
def request_full_url(request, submission):
|
||||
subject = 'Full URL for managing submission of draft %s' % submission.filename
|
||||
from_email = settings.IDSUBMIT_FROM_EMAIL
|
||||
to_email = submission.confirmation_email_list()
|
||||
to_email = submission_confirmation_email_list(submission)
|
||||
url = settings.IDTRACKER_BASE_URL + urlreverse('draft_status_by_hash',
|
||||
kwargs=dict(submission_id=submission.submission_id,
|
||||
submission_hash=submission.get_hash()))
|
||||
|
@ -49,7 +44,6 @@ def request_full_url(request, submission):
|
|||
def perform_post(request, submission):
|
||||
system = Person.objects.get(name="(System)")
|
||||
|
||||
group_id = submission.group_acronym_id or NONE_WG
|
||||
try:
|
||||
draft = Document.objects.get(name=submission.filename)
|
||||
save_document_in_history(draft)
|
||||
|
@ -62,10 +56,11 @@ def perform_post(request, submission):
|
|||
draft.type_id = "draft"
|
||||
draft.time = datetime.datetime.now()
|
||||
draft.title = submission.id_document_name
|
||||
if not (group_id == NONE_WG and draft.group and draft.group.type_id == "area"):
|
||||
group = submission.group_acronym or Group.objects.get(type="individ")
|
||||
if not (group.type_id == "individ" and draft.group and draft.group.type_id == "area"):
|
||||
# don't overwrite an assigned area if it's still an individual
|
||||
# submission
|
||||
draft.group_id = group_id
|
||||
draft.group_id = group.pk
|
||||
draft.rev = submission.revision
|
||||
draft.pages = submission.txt_page_count
|
||||
draft.abstract = submission.abstract
|
||||
|
@ -142,12 +137,13 @@ def perform_post(request, submission):
|
|||
|
||||
submission.save()
|
||||
|
||||
def send_announcements(submission, draft, state_change_msg):
|
||||
announce_to_lists(request, submission)
|
||||
if draft.idinternal and not draft.idinternal.rfc_flag:
|
||||
announce_new_version(request, submission, draft, state_change_msg)
|
||||
announce_to_authors(request, submission)
|
||||
|
||||
def submission_confirmation_email_list(submission):
|
||||
try:
|
||||
doc = Document.objects.get(name=submission.filename)
|
||||
email_list = [i.author.formatted_email() for i in doc.documentauthor_set.all()]
|
||||
except Document.DoesNotExist:
|
||||
email_list = [u'%s <%s>' % i.email() for i in submission.tempidauthors_set.all()]
|
||||
return email_list
|
||||
|
||||
def announce_to_lists(request, submission):
|
||||
authors = []
|
||||
|
@ -156,61 +152,28 @@ def announce_to_lists(request, submission):
|
|||
continue
|
||||
authors.append(i.get_full_name())
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
m = Message()
|
||||
m.by = Person.objects.get(name="(System)")
|
||||
if request.user.is_authenticated():
|
||||
try:
|
||||
m.by = request.user.get_profile()
|
||||
except Person.DoesNotExist:
|
||||
pass
|
||||
m.subject = 'I-D Action: %s-%s.txt' % (submission.filename, submission.revision)
|
||||
m.frm = settings.IDSUBMIT_ANNOUNCE_FROM_EMAIL
|
||||
m.to = settings.IDSUBMIT_ANNOUNCE_LIST_EMAIL
|
||||
if submission.group_acronym:
|
||||
m.cc = submission.group_acronym.email_address
|
||||
m.body = render_to_string('submit/announce_to_lists.txt', dict(submission=submission,
|
||||
authors=authors,
|
||||
settings=settings,))
|
||||
m.save()
|
||||
m.related_docs.add(Document.objects.get(name=submission.filename))
|
||||
m = Message()
|
||||
m.by = Person.objects.get(name="(System)")
|
||||
if request.user.is_authenticated():
|
||||
try:
|
||||
m.by = request.user.get_profile()
|
||||
except Person.DoesNotExist:
|
||||
pass
|
||||
m.subject = 'I-D Action: %s-%s.txt' % (submission.filename, submission.revision)
|
||||
m.frm = settings.IDSUBMIT_ANNOUNCE_FROM_EMAIL
|
||||
m.to = settings.IDSUBMIT_ANNOUNCE_LIST_EMAIL
|
||||
if submission.group_acronym and submission.group_acronym.list_email:
|
||||
m.cc = submission.group_acronym.list_email
|
||||
m.body = render_to_string('submit/announce_to_lists.txt', dict(submission=submission,
|
||||
authors=authors,
|
||||
settings=settings,))
|
||||
m.save()
|
||||
m.related_docs.add(Document.objects.get(name=submission.filename))
|
||||
|
||||
send_mail_message(request, m)
|
||||
else:
|
||||
subject = 'I-D Action: %s-%s.txt' % (submission.filename, submission.revision)
|
||||
from_email = settings.IDSUBMIT_ANNOUNCE_FROM_EMAIL
|
||||
to_email = [settings.IDSUBMIT_ANNOUNCE_LIST_EMAIL]
|
||||
if submission.group_acronym:
|
||||
cc = [submission.group_acronym.email_address]
|
||||
else:
|
||||
cc = None
|
||||
|
||||
send_mail(request, to_email, from_email, subject, 'submit/announce_to_lists.txt',
|
||||
{'submission': submission,
|
||||
'authors': authors}, cc=cc, save_message=True)
|
||||
send_mail_message(request, m)
|
||||
|
||||
|
||||
def announce_new_version(request, submission, draft, state_change_msg):
|
||||
to_email = []
|
||||
if draft.idinternal.state_change_notice_to:
|
||||
to_email.append(draft.idinternal.state_change_notice_to)
|
||||
if draft.idinternal.job_owner:
|
||||
to_email.append(draft.idinternal.job_owner.person.email()[1])
|
||||
try:
|
||||
if draft.idinternal.ballot:
|
||||
for p in draft.idinternal.ballot.positions.all():
|
||||
if p.discuss == 1 and p.ad.user_level == IESGLogin.AD_LEVEL:
|
||||
to_email.append(p.ad.person.email()[1])
|
||||
except BallotInfo.DoesNotExist:
|
||||
pass
|
||||
subject = 'New Version Notification - %s-%s.txt' % (submission.filename, submission.revision)
|
||||
from_email = settings.IDSUBMIT_ANNOUNCE_FROM_EMAIL
|
||||
send_mail(request, to_email, from_email, subject, 'submit/announce_new_version.txt',
|
||||
{'submission': submission,
|
||||
'msg': state_change_msg})
|
||||
|
||||
|
||||
def announce_new_versionREDESIGN(request, submission, draft, state_change_msg):
|
||||
to_email = []
|
||||
if draft.notify:
|
||||
to_email.append(draft.notify)
|
||||
|
@ -241,16 +204,13 @@ def announce_new_versionREDESIGN(request, submission, draft, state_change_msg):
|
|||
{'submission': submission,
|
||||
'msg': state_change_msg})
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
announce_new_version = announce_new_versionREDESIGN
|
||||
|
||||
def announce_to_authors(request, submission):
|
||||
authors = submission.tempidauthors_set.all()
|
||||
to_email = list(set(submission.confirmation_email_list() + [u'%s <%s>' % i.email() for i in authors]))
|
||||
to_email = list(set(submission_confirmation_email_list(submission) + [u'%s <%s>' % i.email() for i in authors]))
|
||||
from_email = settings.IDSUBMIT_ANNOUNCE_FROM_EMAIL
|
||||
subject = 'New Version Notification for %s-%s.txt' % (submission.filename, submission.revision)
|
||||
if submission.group_acronym:
|
||||
wg = submission.group_acronym.group_acronym.acronym
|
||||
wg = submission.group_acronym.acronym
|
||||
elif submission.filename.startswith('draft-iesg'):
|
||||
wg = 'IESG'
|
||||
else:
|
||||
|
@ -261,64 +221,6 @@ def announce_to_authors(request, submission):
|
|||
'wg': wg})
|
||||
|
||||
|
||||
def find_person(first_name, last_name, middle_initial, name_suffix, email):
|
||||
person_list = None
|
||||
if email:
|
||||
person_list = PersonOrOrgInfo.objects.filter(emailaddress__address=email).distinct()
|
||||
if person_list and len(person_list) == 1:
|
||||
return person_list[0]
|
||||
if not person_list:
|
||||
person_list = PersonOrOrgInfo.objects.all()
|
||||
person_list = person_list.filter(first_name=first_name,
|
||||
last_name=last_name)
|
||||
if middle_initial:
|
||||
person_list = person_list.filter(middle_initial=middle_initial)
|
||||
if name_suffix:
|
||||
person_list = person_list.filter(name_suffix=name_suffix)
|
||||
if person_list:
|
||||
return person_list[0]
|
||||
return None
|
||||
|
||||
|
||||
def update_authors(draft, submission):
|
||||
# TempAuthor of order 0 is submitter
|
||||
new_authors = list(submission.tempidauthors_set.filter(author_order__gt=0))
|
||||
person_pks = []
|
||||
for author in new_authors:
|
||||
person = find_person(author.first_name, author.last_name,
|
||||
author.middle_initial, author.name_suffix,
|
||||
author.email_address)
|
||||
if not person:
|
||||
person = PersonOrOrgInfo(
|
||||
first_name=author.first_name,
|
||||
last_name=author.last_name,
|
||||
middle_initial=author.middle_initial or '',
|
||||
name_suffix=author.name_suffix or '',
|
||||
)
|
||||
person.save()
|
||||
if author.email_address:
|
||||
EmailAddress.objects.create(
|
||||
address=author.email_address,
|
||||
priority=1,
|
||||
type='INET',
|
||||
person_or_org=person,
|
||||
)
|
||||
person_pks.append(person.pk)
|
||||
try:
|
||||
idauthor = IDAuthor.objects.get(
|
||||
document=draft,
|
||||
person=person,
|
||||
)
|
||||
idauthor.author_order = author.author_order
|
||||
except IDAuthor.DoesNotExist:
|
||||
idauthor = IDAuthor(
|
||||
document=draft,
|
||||
person=person,
|
||||
author_order=author.author_order,
|
||||
)
|
||||
idauthor.save()
|
||||
draft.authors.exclude(person__pk__in=person_pks).delete()
|
||||
|
||||
def get_person_from_author(author):
|
||||
persons = None
|
||||
|
||||
|
@ -376,7 +278,7 @@ def ensure_person_email_info_exists(author):
|
|||
return email
|
||||
|
||||
|
||||
def update_authorsREDESIGN(draft, submission):
|
||||
def update_authors(draft, submission):
|
||||
# order 0 is submitter
|
||||
authors = []
|
||||
for author in submission.tempidauthors_set.exclude(author_order=0).order_by('author_order'):
|
||||
|
@ -395,26 +297,6 @@ def update_authorsREDESIGN(draft, submission):
|
|||
|
||||
draft.documentauthor_set.exclude(author__in=authors).delete()
|
||||
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
update_authors = update_authorsREDESIGN
|
||||
|
||||
|
||||
def get_person_for_user(user):
|
||||
try:
|
||||
return user.get_profile().person()
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def is_secretariat(user):
|
||||
if not user or not user.is_authenticated():
|
||||
return False
|
||||
return bool(user.groups.filter(name='Secretariat'))
|
||||
|
||||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
from ietf.liaisons.accounts import is_secretariat, get_person_for_user
|
||||
|
||||
def move_docs(submission):
|
||||
for ext in submission.file_type.split(','):
|
||||
source = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s%s' % (submission.filename, submission.revision, ext))
|
||||
|
@ -485,7 +367,7 @@ class DraftValidation(object):
|
|||
return passes_idnits
|
||||
|
||||
def get_working_group(self):
|
||||
if self.draft.group_acronym and self.draft.group_acronym.pk == NONE_WG:
|
||||
if self.draft.group_acronym and self.draft.group_acronym.type_id == "individ":
|
||||
return None
|
||||
return self.draft.group_acronym
|
||||
|
||||
|
@ -529,7 +411,7 @@ class DraftValidation(object):
|
|||
self.add_warning('title', 'Title is empty or was not found')
|
||||
|
||||
def validate_wg(self):
|
||||
if self.wg and not self.wg.status_id == IETFWG.ACTIVE:
|
||||
if self.wg and self.wg.state_id != "active":
|
||||
self.add_warning('group', 'Group exists but is not an active group')
|
||||
|
||||
def validate_abstract(self):
|
||||
|
@ -543,7 +425,7 @@ class DraftValidation(object):
|
|||
if self.draft.status_id in [POSTED, POSTED_BY_SECRETARIAT]:
|
||||
return
|
||||
revision = self.draft.revision
|
||||
existing_revisions = [int(i.revision_display()) for i in InternetDraft.objects.filter(filename=self.draft.filename)]
|
||||
existing_revisions = [int(i.rev) for i in Document.objects.filter(name=self.draft.filename)]
|
||||
expected = 0
|
||||
if existing_revisions:
|
||||
expected = max(existing_revisions) + 1
|
||||
|
@ -575,9 +457,9 @@ class DraftValidation(object):
|
|||
submitter = self.draft.tempidauthors_set.filter(author_order=0)
|
||||
if submitter:
|
||||
return submitter[0]
|
||||
elif self.draft.submitter_tag:
|
||||
try:
|
||||
return PersonOrOrgInfo.objects.get(pk=self.draft.submitter_tag)
|
||||
except PersonOrOrgInfo.DoesNotExist:
|
||||
return False
|
||||
# elif self.draft.submitter_tag:
|
||||
# try:
|
||||
# return PersonOrOrgInfo.objects.get(pk=self.draft.submitter_tag)
|
||||
# except PersonOrOrgInfo.DoesNotExist:
|
||||
# return False
|
||||
return None
|
||||
|
|
|
@ -9,13 +9,13 @@ from django.shortcuts import get_object_or_404
|
|||
from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
|
||||
from ietf.group.models import Group
|
||||
from ietf.group.models import Group, Role
|
||||
from ietf.utils.mail import send_mail
|
||||
from ietf.ietfauth.decorators import has_role, role_required
|
||||
from ietf.ietfauth.utils import has_role, role_required
|
||||
from ietf.submit.models import IdSubmissionDetail, Preapproval
|
||||
from ietf.submit.forms import UploadForm, AutoPostForm, MetaDataForm, PreapprovalForm
|
||||
from ietf.submit.utils import UPLOADED, AWAITING_AUTHENTICATION, MANUAL_POST_REQUESTED, CANCELLED, POSTED, INITIAL_VERSION_APPROVAL_REQUESTED
|
||||
from ietf.submit.utils import is_secretariat, get_approvable_submissions, get_preapprovals, get_recently_approved, get_person_for_user, perform_post, remove_docs, request_full_url
|
||||
from ietf.submit.utils import get_approvable_submissions, get_preapprovals, get_recently_approved, perform_post, remove_docs, request_full_url
|
||||
from ietf.submit.utils import DraftValidation
|
||||
|
||||
def submit_index(request):
|
||||
|
@ -57,10 +57,9 @@ def submit_status(request):
|
|||
|
||||
|
||||
def _can_approve(user, detail):
|
||||
person = get_person_for_user(user)
|
||||
if detail.status_id != INITIAL_VERSION_APPROVAL_REQUESTED or not detail.group_acronym:
|
||||
return None
|
||||
if person in [i.person for i in detail.group_acronym.wgchair_set.all()] or is_secretariat(user):
|
||||
if detail.group_acronym.has_role(user, "chair") or has_role(user, "Secretariat"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -69,14 +68,14 @@ def _can_force_post(user, detail):
|
|||
if detail.status_id not in [MANUAL_POST_REQUESTED,
|
||||
AWAITING_AUTHENTICATION, INITIAL_VERSION_APPROVAL_REQUESTED]:
|
||||
return None
|
||||
if is_secretariat(user):
|
||||
if has_role(user, "Secretariat"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _can_cancel(user, detail, submission_hash):
|
||||
if detail.status_id in [CANCELLED, POSTED]:
|
||||
return None
|
||||
if is_secretariat(user):
|
||||
if has_role(user, "Secretariat"):
|
||||
return True
|
||||
if submission_hash and detail.get_hash() == submission_hash:
|
||||
return True
|
||||
|
@ -85,7 +84,7 @@ def _can_cancel(user, detail, submission_hash):
|
|||
def _can_edit(user, detail, submission_hash):
|
||||
if detail.status_id != UPLOADED:
|
||||
return None
|
||||
if is_secretariat(user):
|
||||
if has_role(user, "Secretariat"):
|
||||
return True
|
||||
if submission_hash and detail.get_hash() == submission_hash:
|
||||
return True
|
||||
|
@ -128,7 +127,7 @@ def draft_status(request, submission_id, submission_hash=None, message=None):
|
|||
submitter = auto_post_form.save_submitter_info()
|
||||
subject = 'New draft waiting for approval: %s' % detail.filename
|
||||
from_email = settings.IDSUBMIT_FROM_EMAIL
|
||||
to_email = list(set(i.person.email()[1] for i in detail.group_acronym.wgchair_set.all()))
|
||||
to_email = [r.formatted_email() for r in Role.objects.filter(group=detail.group_acronym, name="chair").select_related("email", "person")]
|
||||
if to_email:
|
||||
authors = detail.tempidauthors_set.exclude(author_order=0).order_by('author_order')
|
||||
send_mail(request, to_email, from_email, subject, 'submit/submission_approval.txt',
|
||||
|
@ -158,7 +157,7 @@ def draft_status(request, submission_id, submission_hash=None, message=None):
|
|||
show_notify_button = False
|
||||
if allow_edit == False or can_cancel == False:
|
||||
show_notify_button = True
|
||||
if submission_hash is None and is_secretariat(request.user):
|
||||
if submission_hash is None and has_role(request.user, "Secretariat"):
|
||||
submission_hash = detail.get_hash() # we'll need this when rendering the cancel button in the form
|
||||
return render_to_response('submit/draft_status.html',
|
||||
{'selected': 'status',
|
||||
|
@ -285,7 +284,7 @@ def add_preapproval(request):
|
|||
groups = Group.objects.filter(type="wg").exclude(state="conclude").order_by("acronym").distinct()
|
||||
|
||||
if not has_role(request.user, "Secretariat"):
|
||||
groups = groups.filter(role__person=request.user.get_profile())
|
||||
groups = groups.filter(role__person__user=request.user)
|
||||
|
||||
if request.method == "POST":
|
||||
form = PreapprovalForm(request.POST)
|
||||
|
@ -310,7 +309,7 @@ def add_preapproval(request):
|
|||
def cancel_preapproval(request, preapproval_id):
|
||||
preapproval = get_object_or_404(Preapproval, pk=preapproval_id)
|
||||
|
||||
if not preapproval in get_preapprovals(request.user):
|
||||
if preapproval not in get_preapprovals(request.user):
|
||||
raise HttpResponseForbidden("You do not have permission to cancel this preapproval.")
|
||||
|
||||
if request.method == "POST" and request.POST.get("action", "") == "cancel":
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% autoescape off %}
|
||||
A New Internet-Draft is available from the on-line Internet-Drafts directories.
|
||||
{% if submission.group_acronym %} This draft is a work item of the {{ submission.group_acronym.group_acronym.name }} Working Group of the IETF.{% endif %}
|
||||
{% if submission.group_acronym %} This draft is a work item of the {{ submission.group_acronym.name }} Working Group of the IETF.{% endif %}
|
||||
|
||||
Title : {{ submission.id_document_name }}
|
||||
Author(s) : {% for author in authors %}{{ author }}{% if not forloop.last %}
|
||||
|
|
Loading…
Reference in a new issue