- Rename IdSubmissionDetail to Submission - Rename various submission fields to correspond to the conventions in the new schema - Use a name model for the states instead of IdSubmissionStatus - Drop the TempIdAuthor model which is based on splitting up author names - Add a simple textual SubmissionEvent for tracking events in the lifetime of a submission - Delete a bunch of obsolete fields - Make sure all submission have an access key so we can depend on it - Add state for when approval is needed from previous authors A couple of migrations take care of transforming the IdSubmissionDetail and moving data over/cleaning it up. Also revamp the submit view code: - Make form code do validation/cleaning only so there's a clear separation of concerns - Reduce uses of inheritance that made the code hard to follow - forms now don't inherit from each other, views don't call each other but instead reuse common utilities, templates share CSS/utilities instead of relying on inheritance - Move email rendering/sending to separate file - Drop the in-grown terminology use (auto post vs. manual posts) - Make the status page explain who is emailed for what purpose - Add history table with recorded events - Make the status page handle its post actions by itself instead of duplicating most of the setup logic in a number of simple views - Fix a couple of minor bugs and handle some edge cases better - Expand tests with a couple of more cases Possibly the submit tool could still use more help text added to explain the process, ideally what's explained in the tool instructions page should be inlined or self-evident. - Legacy-Id: 6714
84 lines
3 KiB
Python
84 lines
3 KiB
Python
import re, datetime, hashlib
|
|
|
|
from django.conf import settings
|
|
from django.db import models
|
|
|
|
from ietf.person.models import Person
|
|
from ietf.group.models import Group
|
|
from ietf.name.models import DraftSubmissionStateName
|
|
from ietf.utils.uniquekey import generate_unique_key
|
|
|
|
|
|
def parse_email_line(line):
|
|
"""Split line on the form 'Some Name <email@example.com>'"""
|
|
m = re.match("([^<]+) <([^>]+)>$", line)
|
|
if m:
|
|
return dict(name=m.group(1), email=m.group(2))
|
|
else:
|
|
return dict(name=line, email="")
|
|
|
|
class Submission(models.Model):
|
|
state = models.ForeignKey(DraftSubmissionStateName)
|
|
remote_ip = models.CharField(max_length=100, blank=True)
|
|
|
|
access_key = models.CharField(max_length=255, default=generate_unique_key)
|
|
auth_key = models.CharField(max_length=255, blank=True)
|
|
|
|
# draft metadata
|
|
name = models.CharField(max_length=255, db_index=True)
|
|
group = models.ForeignKey(Group, null=True, blank=True)
|
|
title = models.CharField(max_length=255, blank=True)
|
|
abstract = models.TextField(blank=True)
|
|
rev = models.CharField(max_length=3, blank=True)
|
|
pages = models.IntegerField(null=True, blank=True)
|
|
authors = models.TextField(blank=True, help_text="List of author names and emails, one author per line, e.g. \"John Doe <john@example.org>\"")
|
|
note = models.TextField(blank=True)
|
|
replaces = models.CharField(max_length=255, blank=True)
|
|
|
|
first_two_pages = models.TextField(blank=True)
|
|
file_types = models.CharField(max_length=50, blank=True)
|
|
file_size = models.IntegerField(null=True, blank=True)
|
|
document_date = models.DateField(null=True, blank=True)
|
|
submission_date = models.DateField(default=datetime.date.today)
|
|
|
|
submitter = models.CharField(max_length=255, blank=True, help_text="Name and email of submitter, e.g. \"John Doe <john@example.org>\"")
|
|
|
|
idnits_message = models.TextField(blank=True)
|
|
|
|
def __unicode__(self):
|
|
return u"%s-%s" % (self.name, self.rev)
|
|
|
|
def authors_parsed(self):
|
|
res = []
|
|
for line in self.authors.replace("\r", "").split("\n"):
|
|
line = line.strip()
|
|
if line:
|
|
res.append(parse_email_line(line))
|
|
return res
|
|
|
|
def submitter_parsed(self):
|
|
return parse_email_line(self.submitter)
|
|
|
|
|
|
class SubmissionEvent(models.Model):
|
|
submission = models.ForeignKey(Submission)
|
|
time = models.DateTimeField(default=datetime.datetime.now)
|
|
by = models.ForeignKey(Person, null=True, blank=True)
|
|
desc = models.TextField()
|
|
|
|
def __unicode__(self):
|
|
return u"%s %s by %s at %s" % (self.submission.name, self.desc, self.by.plain_name() if self.by else "(unknown)", self.time)
|
|
|
|
class Meta:
|
|
ordering = ("-time", "-id")
|
|
|
|
|
|
class Preapproval(models.Model):
|
|
"""Pre-approved draft submission name."""
|
|
name = models.CharField(max_length=255, db_index=True)
|
|
by = models.ForeignKey(Person)
|
|
time = models.DateTimeField(default=datetime.datetime.now)
|
|
|
|
def __unicode__(self):
|
|
return self.name
|