From 646e8b8615df597cf8f700cf4f1103c799292aca Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Fri, 26 Aug 2011 17:37:44 +0000 Subject: [PATCH] Port WG Delegate deletion with new test - Legacy-Id: 3383 --- ietf/utils/test_data.py | 18 ++- ietf/wgchairs/models.py | 36 +++++- ietf/wgchairs/tests.py | 51 ++++++++ redesign/group/proxy.py | 4 + redesign/name/fixtures/names.xml | 212 ++++++++----------------------- 5 files changed, 158 insertions(+), 163 deletions(-) create mode 100644 ietf/wgchairs/tests.py diff --git a/ietf/utils/test_data.py b/ietf/utils/test_data.py index af9f7e9df..682d7bae0 100644 --- a/ietf/utils/test_data.py +++ b/ietf/utils/test_data.py @@ -92,7 +92,23 @@ def make_test_data(): group=group, email=wgchair, ) - + + # group delegate + u = User.objects.create(username="wgdelegate") + p = Person.objects.create( + name="WG Delegate", + ascii="WG Delegate", + user=u + ) + email = Email.objects.create( + address="wgdelegate@ietf.org", + person=p) + Role.objects.create( + name_id="delegate", + group=group, + email=email, + ) + # secretary u = User.objects.create(username="secretary") p = Person.objects.create( diff --git a/ietf/wgchairs/models.py b/ietf/wgchairs/models.py index 3b57827e3..8909c7e05 100644 --- a/ietf/wgchairs/models.py +++ b/ietf/wgchairs/models.py @@ -1,6 +1,7 @@ import datetime from django.db import models +from django.conf import settings from ietf.idtracker.models import (IETFWG, PersonOrOrgInfo, InternetDraft) @@ -11,7 +12,7 @@ class WGDelegate(models.Model): PersonOrOrgInfo, ) - wg = models.ForeignKey(IETFWG) + wg = models.ForeignKey(IETFWG, related_name="old_wgdelegate_set" if settings.USE_DB_REDESIGN_PROXY_CLASSES else None) def __unicode__(self): return "%s" % self.person @@ -19,7 +20,6 @@ class WGDelegate(models.Model): class Meta: verbose_name = "WG Delegate" - class ProtoWriteUp(models.Model): person = models.ForeignKey( PersonOrOrgInfo, @@ -43,3 +43,35 @@ class ProtoWriteUp(models.Model): blank=False, null=False, ) + +if settings.USE_DB_REDESIGN_PROXY_CLASSES: + from redesign.group.models import Role + class WGDelegateProxy(Role): + #person = models.ForeignKey(PersonOrOrgInfo) + @property + def person(self): + return self.email.person + #wg = models.ForeignKey(IETFWG) + @property + def wg(self): + return self.group + + def __unicode__(self): + return u"%s" % self.person + + class Meta: + proxy = True + + from redesign.doc.models import DocEvent + class ProtoWriteUpProxy(DocEvent): + #person = models.ForeignKey(PersonOrOrgInfo, blank=False, null=False) + #draft = models.ForeignKey(InternetDraft, blank=False, null=False) + #date = models.DateTimeField(default=datetime.datetime.now(), blank=False, null=False) + #writeup = models.TextField(blank=False, null=False) + class Meta: + proxy = True + + #WGDelegateOld = WGDelegate + WGDelegate = WGDelegateProxy + ProtoWriteUpOld = ProtoWriteUp + ProtoWriteUp = ProtoWriteUpProxy diff --git a/ietf/wgchairs/tests.py b/ietf/wgchairs/tests.py new file mode 100644 index 000000000..9f61eb9ef --- /dev/null +++ b/ietf/wgchairs/tests.py @@ -0,0 +1,51 @@ +import datetime, os, shutil + +from django.conf import settings +from django.contrib.auth.models import User +from django.core.urlresolvers import reverse as urlreverse +import django.test +from StringIO import StringIO +from pyquery import PyQuery + +from ietf.utils.test_utils import login_testing_unauthorized +from ietf.utils.test_runner import mail_outbox +from ietf.utils.test_data import make_test_data + +if settings.USE_DB_REDESIGN_PROXY_CLASSES: + from redesign.person.models import Person, Email + from redesign.group.models import Group, Role + +class ManageDelegatesTestCase(django.test.TestCase): + fixtures = ['names'] + + def test_delete_delegate(self): + make_test_data() + + url = urlreverse('manage_delegates', kwargs=dict(acronym="mars")) + login_testing_unauthorized(self, "secretary", url) + + delegates = Role.objects.filter(name="delegate", group__acronym="mars") + self.assertTrue(len(delegates) > 0) + + # get + r = self.client.get(url) + self.assertEquals(r.status_code, 200) + q = PyQuery(r.content) + self.assertEquals(len(q('form input[name=delete]')), len(delegates)) + + # delete + r = self.client.post(url, + dict(remove="1", + delete=[d.pk for d in delegates])) + self.assertEquals(r.status_code, 200) + q = PyQuery(r.content) + self.assertEquals(len(q('form input[name=delete]')), 0) + self.assertEquals(Role.objects.filter(name="delegate", group__acronym="mars").count(), 0) + + + + + +if not settings.USE_DB_REDESIGN_PROXY_CLASSES: + # the above tests only work with the new schema + del ManageDelegatesTestCase diff --git a/redesign/group/proxy.py b/redesign/group/proxy.py index 1084c7e2f..4f992538c 100644 --- a/redesign/group/proxy.py +++ b/redesign/group/proxy.py @@ -209,6 +209,10 @@ class IETFWG(Group): d = Dummy() d.all = self.chairs() return d + @property + def wgdelegate_set(self): + from ietf.wgchairs.models import WGDelegate + return WGDelegate.objects.filter(group=self, name="delegate") class Meta: proxy = True diff --git a/redesign/name/fixtures/names.xml b/redesign/name/fixtures/names.xml index 3baf7ee5d..0144b0e6b 100644 --- a/redesign/name/fixtures/names.xml +++ b/redesign/name/fixtures/names.xml @@ -1,13 +1,13 @@ - - Yes + + No Objection 1 0 - - No Objection + + Yes 1 0 @@ -54,24 +54,6 @@ 1 0 - - IANA coordination - RFC-Editor/IANA Registration Coordination - 1 - 0 - - - Missing references - Awaiting missing normative reference - 1 - 0 - - - FastTrack - - 1 - 0 - Review by RFC Editor @@ -102,12 +84,6 @@ 1 0 - - Holding for references - Holding for normative reference - 1 - 0 - Point Raised - writeup needed IESG discussions on the document have raised some issues that need to be brought to the attention of the authors/WG, but those issues have not been written down yet. (It is common for discussions during a telechat to result in such situations. An AD may raise a possible issue during a telechat and only decide as a result of that discussion whether the issue is worth formally writing up and bringing to the attention of the authors/WG). A document stays in the "Point Raised - Writeup Needed" state until *ALL* IESG comments that have been raised have been documented. @@ -138,14 +114,14 @@ 1 5 - - Updates + + Replaces 1 0 - - Replaces + + Updates 1 0 @@ -156,20 +132,8 @@ 1 0 - - Reviews - - 1 - 0 - - - References - - 1 - 0 - - - RFC + + Active 1 0 @@ -180,14 +144,8 @@ 1 0 - - Replaced - - 1 - 0 - - - Active + + RFC 1 0 @@ -198,12 +156,24 @@ 1 0 + + Replaced + + 1 + 0 + Withdrawn by IETF 1 0 + + Legacy + + 1 + 0 + IETF @@ -216,12 +186,6 @@ 1 0 - - Legacy - - 1 - 0 - IAB @@ -234,18 +198,6 @@ 1 0 - - Draft - - 1 - 0 - - - External - - 1 - 0 - Agenda @@ -264,6 +216,12 @@ 1 0 + + Draft + + 1 + 0 + Liaison Attachment @@ -318,15 +276,21 @@ 1 0 + + AG + Area group + 1 + 0 + WG - + Working group 1 0 RG - + Research group 1 0 @@ -342,15 +306,9 @@ 1 0 - - AG - - 1 - 0 - - Standards Organization - + SDO + Standards organization 1 0 @@ -534,72 +492,6 @@ 1 0 - - AUTH - Awaiting author action - 1 - 0 - - - AUTH48 - Awaiting final author approval - 1 - 0 - - - EDIT - Approved by the stream manager (e.g., IESG, IAB, IRSG, ISE), awaiting processing and publishing - 1 - 0 - - - IANA - RFC-Editor/IANA Registration Coordination - 1 - 0 - - - IESG - Holding for IESG action - 1 - 0 - - - ISR - Independent Submission Review by the ISE - 1 - 0 - - - ISR-AUTH - Independent Submission awaiting author update, or in discussion between author and ISE - 1 - 0 - - - REF - Holding for normative reference - 1 - 0 - - - RFC-EDITOR - Awaiting final RFC Editor review before AUTH48 - 1 - 0 - - - TO - Time-out period during which the IESG reviews document for conflict/concurrence with other IETF working group work - 1 - 0 - - - MISSREF - Awaiting missing normative reference - 1 - 0 - Area Director @@ -636,12 +528,6 @@ 1 0 - - Executive Director - - 1 - 0 - Executive Director @@ -666,6 +552,12 @@ 1 0 + + Delegate + + 1 + 0 + Waiting for Scheduling @@ -768,16 +660,16 @@ 1 0 - - Other - - 1 - 0 - Plenary 1 0 + + Other + + 1 + 0 + \ No newline at end of file