From d981d5a617e6f1ff73ed1365d81ae2fc5f359ced Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Tue, 22 May 2007 22:15:13 +0000
Subject: [PATCH] Template formatting changes, to more easily see what's going
 on.  And sorting on area within the timeslot.  - Legacy-Id: 152

---
 ietf/ipr/models.py                 | 16 +++++----
 ietf/ipr/view_new.py               | 17 ++++++++--
 ietf/ipr/view_sections.py          |  9 +++--
 ietf/ipr/views.py                  | 12 ++++---
 ietf/templates/ipr/details.html    |  3 ++
 ietf/templates/meeting/agenda.html | 54 +++++++++++++++---------------
 6 files changed, 66 insertions(+), 45 deletions(-)

diff --git a/ietf/ipr/models.py b/ietf/ipr/models.py
index 27faf15d4..77700bc90 100644
--- a/ietf/ipr/models.py
+++ b/ietf/ipr/models.py
@@ -79,11 +79,11 @@ class IprDetail(models.Model):
 
     # Patent Information fieldset
     p_applications = models.TextField("Patent Applications", maxlength=255)
-    date_applied = models.DateField(maxlength=255)
+    date_applied = models.CharField(maxlength=255)
     country = models.CharField(maxlength=100)
     p_notes = models.TextField("Additional notes", blank=True)
-    selecttype = models.IntegerField("Unpublished Pending Patent Application", null=True, choices=SELECT_CHOICES)
-    selectowned = models.IntegerField("Applies to all IPR owned by Submitter", null=True, blank=True, choices=SELECT_CHOICES)
+    selecttype = models.IntegerField("Unpublished Pending Patent Application", choices=SELECT_CHOICES)
+    selectowned = models.IntegerField("Applies to all IPR owned by Submitter", choices=SELECT_CHOICES)
 
     # Licensing Declaration fieldset
     #licensing_option = models.ForeignKey(IprLicensing, db_column='licensing_option')
@@ -94,16 +94,18 @@ class IprDetail(models.Model):
     comments = models.TextField("Licensing Comments", blank=True)
     lic_checkbox = models.BooleanField("All terms and conditions has been disclosed")
 
-    third_party = models.BooleanField(editable=False)
 
     # Other notes fieldset
     other_notes = models.TextField(blank=True)
 
     # Generated fields, not part of the submission form
+    # Hidden fields
+    third_party = models.BooleanField()
+    generic = models.BooleanField()
+    comply = models.BooleanField()
+
     status = models.IntegerField(null=True, blank=True)
-    comply = models.BooleanField(editable=False)
-    generic = models.BooleanField(editable=False)
-    submitted_date = models.DateField(null=True, blank=True)
+    submitted_date = models.DateField(blank=True)
     update_notified_date = models.DateField(null=True, blank=True)
 
     def __str__(self):
diff --git a/ietf/ipr/view_new.py b/ietf/ipr/view_new.py
index 9e9ba806e..901cfb689 100644
--- a/ietf/ipr/view_new.py
+++ b/ietf/ipr/view_new.py
@@ -7,6 +7,7 @@ from django.shortcuts import render_to_response as render
 from ietf.utils import log
 from ietf.ipr.view_sections import section_table
 from ietf.idtracker.models import Rfc, InternetDraft
+from django.http import HttpResponseRedirect
 
 # ----------------------------------------------------------------
 # Callback methods for special field cases.
@@ -20,6 +21,8 @@ def ipr_detail_form_callback(field, **kwargs):
     if field.name in ["rfc_number", "id_document_tag"]:
         log(field.name)
         return forms.CharFieldField(required=False)
+    if field.name in ["date_applied"]:
+        return forms.DateField()
     return field.formfield(**kwargs)
 
 def ipr_contact_form_callback(field, **kwargs):
@@ -154,7 +157,15 @@ def new(request, type):
                         raise forms.ValidationError("Unknown Internet-Draft: %s - please correct this." % filename)
                     if rev and id.revision != rev:
                         raise forms.ValidationError("Unexpected revision '%s' for draft %s - the current revision is %s.  Please check this." % (rev, filename, id.revision))
-            pass
+        def clean_document_title(self):
+            log("clean_data: %s" % self.data)
+            if type == "general":
+                return """%(p_h_legal_name)s's license statement""" % self.data
+            if type == "specific":
+                return """%(p_h_legal_name)s's Statement about IPR related to ...""" % self.data
+            if type == "third-party":
+                return """%(submitter)s's Statement about IPR related to ... belonging to %(p_h_legal_name)s""" % self.data
+            raise KeyError("Unexpected IPR disclosure type '%s'" % type)
 
     if request.method == 'POST':
         data = request.POST.copy()
@@ -170,8 +181,8 @@ def new(request, type):
         if form.ietf_contact_is_submitter:
             form.ietf_contact_is_submitter_checked = "checked"
         if form.is_valid():
-            #instance = form.save()
-            #return HttpResponseRedirect("/ipr/ipr-%s" % instance.ipr_id)
+            instance = form.save()
+            return HttpResponseRedirect("/ipr/ipr-%s" % instance.ipr_id)
             #return HttpResponseRedirect("/ipr/")
         
             pass
diff --git a/ietf/ipr/view_sections.py b/ietf/ipr/view_sections.py
index e5d2168d5..a7fa691c0 100644
--- a/ietf/ipr/view_sections.py
+++ b/ietf/ipr/view_sections.py
@@ -1,7 +1,8 @@
 
 section_table = {
                 "index":    {   "index": True   },
-                "specific": {   "index": False, "title": True, "specific": True,
+                "specific": {   "index": False, "title": True,
+                                "specific": 1, "generic": 0, "third_party": 0, 
                                 "legacy_intro": False, "new_intro": True,  "form_intro": False,
                                 "holder": True, "holder_contact": True, "ietf_contact": True,
                                 "ietf_doc": True, "patent_info": True, "licensing": True,
@@ -9,7 +10,8 @@ section_table = {
                                 "disclosure_type": "Specific", "form_legend": False, 
                                 "per_rfc_disclosure": True, "also_specific": False,
                             },
-                "generic": {   "index": False, "title": True, "generic": True,
+                "generic": {   "index": False, "title": True,
+                                "specific": 0, "generic": 1, "third_party": 0, 
                                 "legacy_intro": False, "new_intro": True,  "form_intro": False,
                                 "holder": True, "holder_contact": True, "ietf_contact": False,
                                 "ietf_doc": False, "patent_info": True, "licensing": True,
@@ -17,7 +19,8 @@ section_table = {
                                 "disclosure_type": "Generic", "form_legend": False, 
                                 "per_rfc_disclosure": False, "also_specific": True,
                             },
-                "third-party": {"index": False, "title": True, "third_party": True, 
+                "third-party": {"index": False, "title": True,
+                                "specific": 0, "generic": 0, "third_party": 1, 
                                 "legacy_intro": False, "new_intro": True,  "form_intro": False,
                                 "holder": True, "holder_contact": False, "ietf_contact": True,
                                 "ietf_doc": True, "patent_info": True, "licensing": False,
diff --git a/ietf/ipr/views.py b/ietf/ipr/views.py
index 5284c729a..739119e02 100644
--- a/ietf/ipr/views.py
+++ b/ietf/ipr/views.py
@@ -5,6 +5,7 @@ from django.shortcuts import render_to_response as render
 from django.utils.html import escape
 from ietf.ipr.view_new import new
 from ietf.ipr.view_sections import section_table
+from ietf.utils import log
 
 def linebreaks(value):
     if value:
@@ -62,9 +63,10 @@ def show(request, ipr_id=None):
     ipr.comments = linebreaks(escape(ipr.comments))
     ipr.other_notes = linebreaks(escape(ipr.other_notes))
 
-    ipr.licensing_option = dict(models.LICENSE_CHOICES)[ipr.licensing_option]
-    ipr.selecttype = dict(models.SELECT_CHOICES)[ipr.selecttype]
-
+    if ipr.licensing_option:
+        ipr.licensing_option = dict(models.LICENSE_CHOICES)[ipr.licensing_option]
+    if ipr.selecttype:
+        ipr.selecttype = dict(models.SELECT_CHOICES)[ipr.selecttype]
     if ipr.selectowned:
         ipr.selectowned = dict(models.SELECT_CHOICES)[ipr.selectowned]
     return render("ipr/details.html",  {"ipr": ipr, "section_list": section_list})
@@ -82,9 +84,9 @@ def get_section_list(ipr):
     if   ipr.old_ipr_url:
         return section_table["legacy"]
     elif ipr.generic:
-        assert not ipr.third_party
+        #assert not ipr.third_party
         return section_table["generic"]
     elif ipr.third_party:
-        return section_table["third_party"]
+        return section_table["third-party"]
     else:
         return section_table["specific"]
diff --git a/ietf/templates/ipr/details.html b/ietf/templates/ipr/details.html
index f3d843f1b..b56385833 100644
--- a/ietf/templates/ipr/details.html
+++ b/ietf/templates/ipr/details.html
@@ -475,6 +475,9 @@
       {% endif %}
 
       {% if section_list.form_submit %}
+      <input type="hidden" name="third_party" value="{{ section_list.third_party }}">
+      <input type="hidden" name="generic" value="{{ section_list.generic }}">
+      <input type="hidden" name="comply" value="1">
       <center><input type="submit" name="submit" value="Submit"></center>
       </form>
       <blockquote>
diff --git a/ietf/templates/meeting/agenda.html b/ietf/templates/meeting/agenda.html
index b6503a3ac..ce40a44d4 100644
--- a/ietf/templates/meeting/agenda.html
+++ b/ietf/templates/meeting/agenda.html
@@ -22,32 +22,32 @@ Updated As of : {% now "F j, Y" %}<br />
 <br>
 {% regroup object_list by day_id as days %}
 {% for day in days %}
-<b>Day: {{ day.list.1.meeting_date|date:"l, F j, Y" }} </b><br>
-{{ day.list.1.reg_info }} - {{ meetingvenue_info.reg_area_name }} <br>
-{{ day.list.1.morning_br_info }} - {{ meetingvenue_info.break_area_name }} <br>
-<br>
-{% for item in day.list %}
-{% ifequal item.session_name_id 3 %}
-{{ day.list.1.lunch_br_info }} Break<br>
-{% endifequal %}
-{% ifequal item.session_name_id 4 %}
-{{ day.list.1.an_br1_info }}<br>
-{% endifequal %}
-{% ifequal item.session_name_id 5 %}
-{{ day.list.1.an_br2_info }}<br>
-{% endifequal %}
-<b>{{ item.time_desc }} {{ item.session_name }} </b><br>
-<table border="0" cellspacing="0" cellpadding="0" width="800">
-{% for session in item.sessions|dictsort:"area" %}
-{% ifequal session.acronym "plenaryw" %}
-<tr><td>{{ op_ad_plenary_agenda|linebreaksbr }}</td></tr>
-{% else %}
-<tr><td width="200">{{ session.sched_room_id1.room_name }}</td><td width="50">{{ session.area|upper }}</td><td width="100">{{ session.acronym }}</td><td>{{ session.acronym_name }}</td></tr>
-{% endifequal %}
-{% endfor %}
-</table>
-<br>
-{% endfor %}
-<br>
+   <b>Day: {{ day.list.1.meeting_date|date:"l, F j, Y" }} </b><br>
+   {{ day.list.1.reg_info }} - {{ meetingvenue_info.reg_area_name }} <br>
+   {{ day.list.1.morning_br_info }} - {{ meetingvenue_info.break_area_name }} <br>
+   <br>
+   {% for item in day.list %}
+      {% ifequal item.session_name_id 3 %}
+	 {{ day.list.1.lunch_br_info }} Break<br>
+      {% endifequal %}
+      {% ifequal item.session_name_id 4 %}
+	 {{ day.list.1.an_br1_info }}<br>
+      {% endifequal %}
+      {% ifequal item.session_name_id 5 %}
+	 {{ day.list.1.an_br2_info }}<br>
+      {% endifequal %}
+      <b>{{ item.time_desc }} {{ item.session_name }} </b><br>
+      <table border="0" cellspacing="0" cellpadding="0" width="800">
+      {% for session in item.sessions|dictsort:"area" %}
+	 {% ifequal session.acronym "plenaryw" %}
+	    <tr><td>{{ op_ad_plenary_agenda|linebreaksbr }}</td></tr>
+	 {% else %}
+	    <tr><td width="200">{{ session.sched_room_id1.room_name }}</td><td width="50">{{ session.area|upper }}</td><td width="100">{{ session.acronym }}</td><td>{{ session.acronym_name }}</td></tr>
+	 {% endifequal %}
+      {% endfor %}
+      </table>
+      <br>
+   {% endfor %}
+   <br>
 {% endfor %}
 {% endblock %}