From d176d2b161f22b935147805a617c7f2028d2404d Mon Sep 17 00:00:00 2001 From: Ole Laursen <olau@iola.dk> Date: Tue, 24 Apr 2012 13:23:56 +0000 Subject: [PATCH] Copy charter text so we have an appriopriately named charter file when renaming group acronyms. - Legacy-Id: 4315 --- ietf/wginfo/edit.py | 25 +++++++++++++++---------- ietf/wginfo/tests.py | 3 +++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ietf/wginfo/edit.py b/ietf/wginfo/edit.py index ba35f6a38..6ae1319fb 100644 --- a/ietf/wginfo/edit.py +++ b/ietf/wginfo/edit.py @@ -1,6 +1,6 @@ # edit/create view for WGs -import re, os, string, datetime +import re, os, string, datetime, shutil from django.shortcuts import render_to_response, get_object_or_404, redirect from django.core.urlresolvers import reverse @@ -142,14 +142,8 @@ def edit(request, acronym=None, action="edit"): if r[attr] != v: changes.append(desc(name, r[attr], v)) setattr(wg, attr, r[attr]) - if attr == "acronym": - c = wg.charter - save_document_in_history(c) - # and add a DocAlias - DocAlias.objects.create( - name="charter-ietf-%s" % r['acronym'], - document=c, - ) + + prev_acronym = wg.acronym # update the attributes, keeping track of what we're doing diff('name', "Name") @@ -159,7 +153,18 @@ def edit(request, acronym=None, action="edit"): diff('list_email', "Mailing list email") diff('list_subscribe', "Mailing list subscribe address") diff('list_archive', "Mailing list archive") - + + if not new_wg and wg.acronym != prev_acronym: + save_document_in_history(wg.charter) + DocAlias.objects.get_or_create( + name="charter-ietf-%s" % wg.acronym, + document=wg.charter, + ) + old = os.path.join(wg.charter.get_file_path(), 'charter-ietf-%s-%s.txt' % (prev_acronym, wg.charter.rev)) + if os.path.exists(old): + new = os.path.join(wg.charter.get_file_path(), 'charter-ietf-%s-%s.txt' % (wg.acronym, wg.charter.rev)) + shutil.copy(old, new) + # update roles for attr, slug, title in [('chairs', 'chair', "Chairs"), ('secretaries', 'secr', "Secretaries"), ('techadv', 'techadv', "Tech Advisors")]: new = r[attr] diff --git a/ietf/wginfo/tests.py b/ietf/wginfo/tests.py index 9e27ef32c..51e34d0b2 100644 --- a/ietf/wginfo/tests.py +++ b/ietf/wginfo/tests.py @@ -157,6 +157,8 @@ class WgEditTestCase(django.test.TestCase): self.assertTrue(len(q('form ul.errorlist')) > 0) # edit info + with open(os.path.join(self.charter_dir, "%s-%s.txt" % (group.charter.canonical_name(), group.charter.rev)), "w") as f: + f.write("This is a charter.") area = group.parent ad = Person.objects.get(name="Aread Irector") r = self.client.post(url, @@ -185,6 +187,7 @@ class WgEditTestCase(django.test.TestCase): self.assertEquals(group.list_archive, "archive.mars") self.assertEquals(group.groupurl_set.all()[0].url, "http://mars.mars") self.assertEquals(group.groupurl_set.all()[0].name, "MARS site") + self.assertTrue(os.path.exists(os.path.join(self.charter_dir, "%s-%s.txt" % (group.charter.canonical_name(), group.charter.rev)))) def test_conclude(self): make_test_data()