[damned-lies] Rename ActionDbBackup to ActionDBArchived
- From: Stéphane Raimbault <stephaner src gnome org>
- To: svn-commits-list gnome org
- Subject: [damned-lies] Rename ActionDbBackup to ActionDBArchived
- Date: Sat, 23 May 2009 09:46:42 -0400 (EDT)
commit ccde0ea1f2484d357f996b0dd9a5af14c2430904
Author: Stéphane Raimbault <stephane raimbault gmail com>
Date: Thu May 21 16:08:03 2009 +0200
Rename ActionDbBackup to ActionDBArchived
- rename ArchivedStatistics to StatisticsArchived
- rename ArchivedInformation to InformationArchived
- rename BA to AA
---
docs/notes-upgrade.txt | 16 +++++++++++++-
settings_sample.py | 2 +-
stats/models.py | 10 ++++----
vertimus/feeds.py | 6 ++--
vertimus/models.py | 48 ++++++++++++++++++++++----------------------
vertimus/tests/__init__.py | 26 +++++++++++-----------
6 files changed, 61 insertions(+), 47 deletions(-)
diff --git a/docs/notes-upgrade.txt b/docs/notes-upgrade.txt
index 345deee..bad30f5 100644
--- a/docs/notes-upgrade.txt
+++ b/docs/notes-upgrade.txt
@@ -47,7 +47,7 @@ ALTER TABLE team ALTER name SET NOT NULL;
ALTER TABLE team DROP group_ptr_id CASCADE;
ALTER TABLE language ADD FOREIGN KEY (team_id) REFERENCES team(id);
-## r1412
+## r1412
# For MySQL
ALTER TABLE statistics ADD num_figures int(11) NOT NULL DEFAULT 0;
# For PostgreSQL
@@ -72,3 +72,17 @@ for stat in stats:
## r1447
ALTER TABLE information MODIFY `type` VARCHAR(10) NOT NULL;
ALTER TABLE archived_information MODIFY `type` VARCHAR(10) NOT NULL;
+
+## Rename archives tables
+ALTER TABLE archived_statistics RENAME TO statistics_archived;
+ALTER TABLE archived_information RENAME TO information_archived;
+ALTER TABLE action_backup RENAME TO action_archived;
+UPDATE action_archived SET name = 'AA' where name = 'BA';
+
+# For PostgreSQL
+ALTER INDEX action_backup_pkey RENAME TO action_archived_pkey;
+ALTER INDEX archived_information_pkey RENAME TO information_archived_pkey;
+ALTER INDEX archived_statistics_pkey RENAME TO statistics_archived_pkey;
+ALTER SEQUENCE action_backup_id_seq RENAME TO action_archived_id_seq;
+ALTER SEQUENCE archived_information_id_seq RENAME TO information_archived_id_seq;
+ALTER SEQUENCE archived_statistics_id_seq RENAME TO statistics_archived_id_seq;
diff --git a/settings_sample.py b/settings_sample.py
index 4447e20..4223393 100644
--- a/settings_sample.py
+++ b/settings_sample.py
@@ -81,7 +81,7 @@ VCS_HOME_WARNING = gettext_noop(u"This module is not part of the GNOME git repos
# By default, Django stores files locally, using the MEDIA_ROOT and MEDIA_URL settings
UPLOAD_DIR = 'upload'
-UPLOAD_BACKUP_DIR = 'upload-backup'
+UPLOAD_ARCHIVED_DIR = 'upload-archived'
FILE_UPLOAD_PERMISSIONS = 0600
diff --git a/stats/models.py b/stats/models.py
index 787f2e3..c6f7c51 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1295,7 +1295,7 @@ class FakeStatistics(object):
def most_important_message(self):
return None
-class ArchivedStatistics(models.Model):
+class StatisticsArchived(models.Model):
module = models.TextField()
type = models.CharField(max_length=3, choices=DOMAIN_TYPE_CHOICES)
domain = models.TextField()
@@ -1307,7 +1307,7 @@ class ArchivedStatistics(models.Model):
untranslated = models.IntegerField(default=0)
class Meta:
- db_table = 'archived_statistics'
+ db_table = 'statistics_archived'
INFORMATION_TYPE_CHOICES = (
('info', 'Information'),
@@ -1358,11 +1358,11 @@ class Information(models.Model):
text = text.replace('%s',match,1)
return text
-class ArchivedInformation(models.Model):
- statistics = models.ForeignKey('ArchivedStatistics')
+class InformationArchived(models.Model):
+ statistics = models.ForeignKey('StatisticsArchived')
# Priority of a stats message
type = models.CharField(max_length=10, choices=INFORMATION_TYPE_CHOICES)
description = models.TextField()
class Meta:
- db_table = 'archived_information'
+ db_table = 'information_archived'
diff --git a/vertimus/feeds.py b/vertimus/feeds.py
index 5254384..6e9402c 100644
--- a/vertimus/feeds.py
+++ b/vertimus/feeds.py
@@ -26,7 +26,7 @@ from django.utils.translation import ugettext_lazy as _
from django.contrib.sites.models import Site
from languages.models import Language
from teams.models import Team
-from vertimus.models import ActionDb, ActionDbBackup
+from vertimus.models import ActionDb, ActionDbArchived
from common.utils import imerge_sorted_by_field
class LatestActionsByLanguage(Feed):
@@ -55,7 +55,7 @@ class LatestActionsByLanguage(Feed):
# The Django ORM doesn't provide the UNION SQL feature :-(
# so we need to fetch twice more objects than required
actions_db = ActionDb.objects.filter(state_db__language=obj.id).select_related('state').order_by('-created')[:20]
- archived_actions_db = ActionDbBackup.objects.filter(state_db__language=obj.id).select_related('state').order_by('-created')[:20]
+ archived_actions_db = ActionDbArchived.objects.filter(state_db__language=obj.id).select_related('state').order_by('-created')[:20]
# islice avoid to fetch too many objects
return (action_db.get_action() for action_db in islice(imerge_sorted_by_field(actions_db, archived_actions_db, '-created'), 20))
@@ -100,7 +100,7 @@ class LatestActionsByTeam(Feed):
# The Django ORM doesn't provide the UNION SQL feature :-(
# so we need to fetch twice more objects than required
actions_db = ActionDb.objects.filter(state_db__language__team=obj.id).select_related('state').order_by('-created')[:20]
- archived_actions_db = ActionDbBackup.objects.filter(state_db__language__team=obj.id).select_related('state').order_by('-created')[:20]
+ archived_actions_db = ActionDbArchived.objects.filter(state_db__language__team=obj.id).select_related('state').order_by('-created')[:20]
a = imerge_sorted_by_field(actions_db, archived_actions_db, '-created')
b = islice(imerge_sorted_by_field(actions_db, archived_actions_db, '-created'), 20)
diff --git a/vertimus/models.py b/vertimus/models.py
index 8306588..6ef7e15 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (c) 2008 Stéphane Raimbault <stephane raimbault gmail com>
+# Copyright (c) 2008-2009 Stéphane Raimbault <stephane raimbault gmail com>
#
# This file is part of Damned Lies.
#
@@ -104,7 +104,7 @@ class StateAbstract(object):
if person.is_committer(self.language.team) and 'IC' not in action_names:
action_names.extend(('Separator', 'IC'))
if self.name not in ('None', 'Committed'):
- action_names.append('BA')
+ action_names.append('AA')
return [eval('Action' + action_name)() for action_name in action_names]
def apply_action(self, action, person, comment=None, file=None):
@@ -122,8 +122,8 @@ class StateAbstract(object):
# Committed is the last state of the workflow
new_state.save()
- # Backup actions
- return new_state.apply_action(ActionBA(), person)
+ # Archive actions
+ return new_state.apply_action(ActionAA(), person)
return new_state
else:
@@ -255,7 +255,7 @@ class StateCommitted(StateAbstract):
def get_available_actions(self, person):
if person.is_committer(self.language.team):
- action_names = ['BA']
+ action_names = ['AA']
else:
action_names = []
@@ -271,7 +271,7 @@ ACTION_NAMES = (
'RP', 'UP',
'TC', 'CI', 'RC',
'IC', 'TR',
- 'BA', 'UNDO')
+ 'AA', 'UNDO')
def generate_upload_filename(instance, filename):
# Extract the first extension (with the point)
@@ -666,21 +666,21 @@ class ActionTR(ActionAbstract):
self.send_mail_new_state(state, new_state, (state.language.team.mailing_list,))
return new_state
-def generate_backup_filename(instance, original_filename):
- return "%s/%s" % (settings.UPLOAD_BACKUP_DIR, os.path.basename(original_filename))
+def generate_archive_filename(instance, original_filename):
+ return "%s/%s" % (settings.UPLOAD_ARCHIVED_DIR, os.path.basename(original_filename))
-class ActionDbBackup(models.Model):
+class ActionDbArchived(models.Model):
state_db = models.ForeignKey(StateDb)
person = models.ForeignKey(Person)
name = models.SlugField(max_length=8)
created = models.DateTimeField(auto_now_add=True, editable=False)
comment = models.TextField(blank=True, null=True)
- file = models.FileField(upload_to=generate_backup_filename, blank=True, null=True)
+ file = models.FileField(upload_to=generate_archive_filename, blank=True, null=True)
sequence = models.IntegerField(blank=True, null=True)
class Meta:
- db_table = 'action_backup'
+ db_table = 'action_archived'
def __unicode__(self):
return "%s (%s)" % (self.name, self.id)
@@ -690,9 +690,9 @@ class ActionDbBackup(models.Model):
action._action_db = self
return action
-class ActionBA(ActionAbstract):
- name = 'BA'
- description = _('Backup the actions')
+class ActionAA(ActionAbstract):
+ name = 'AA'
+ description = _('Archive the actions')
def _new_state(self):
return StateNone()
@@ -704,26 +704,26 @@ class ActionBA(ActionAbstract):
sequence = None
for action_db in actions_db:
- file_to_backup = None
+ file_to_archive = None
if action_db.file:
- file_to_backup = action_db.file.file # get a file object, not a filefield
- action_db_backup = ActionDbBackup(
+ file_to_archive = action_db.file.file # get a file object, not a filefield
+ action_db_archived = ActionDbArchived(
state_db=action_db.state_db,
person=action_db.person,
name=action_db.name,
created=action_db.created,
comment=action_db.comment,
- file=file_to_backup)
- if file_to_backup:
- action_db_backup.file.save(action_db.file.name, file_to_backup, save=False)
+ file=file_to_archive)
+ if file_to_archive:
+ action_db_archived.file.save(action_db.file.name, file_to_archive, save=False)
if sequence == None:
# The ID is available after the save()
- action_db_backup.save()
- sequence = action_db_backup.id
+ action_db_archived.save()
+ sequence = action_db_archived.id
- action_db_backup.sequence = sequence
- action_db_backup.save()
+ action_db_archived.sequence = sequence
+ action_db_archived.save()
action_db.delete() # The file is also automatically deleted, if it is not referenced elsewhere
diff --git a/vertimus/tests/__init__.py b/vertimus/tests/__init__.py
index a118be3..cfb2f73 100644
--- a/vertimus/tests/__init__.py
+++ b/vertimus/tests/__init__.py
@@ -145,7 +145,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['WC', None, 'IC', 'AA'])
# Same person
action_names = [a.name for a in state.get_available_actions(self.pt)]
@@ -168,7 +168,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['RP', 'RT', 'TR', 'WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['RP', 'RT', 'TR', 'WC', None, 'IC', 'AA'])
def test_state_proofreading(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
@@ -182,7 +182,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['WC', None, 'IC', 'AA'])
# Same person and reviewer
action_names = [a.name for a in state.get_available_actions(self.pr)]
@@ -203,7 +203,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['TC', 'RP', 'TR', 'WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['TC', 'RP', 'TR', 'WC', None, 'IC', 'AA'])
def test_state_to_review(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pt)
@@ -220,7 +220,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['RT', 'WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['RT', 'WC', None, 'IC', 'AA'])
def test_state_to_commit(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
@@ -234,7 +234,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['RC', 'TR', 'WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['RC', 'TR', 'WC', None, 'IC', 'AA'])
def test_state_committing(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pc)
@@ -247,7 +247,7 @@ class VertimusTest(TestCase):
self.assertEqual(action_names, ['WC'])
action_names = [a.name for a in state.get_available_actions(self.pcoo)]
- self.assertEqual(action_names, ['WC', None, 'IC', 'BA'])
+ self.assertEqual(action_names, ['WC', None, 'IC', 'AA'])
action_names = [a.name for a in state.get_available_actions(self.pc)]
self.assertEqual(action_names, ['IC', 'TR', 'UNDO', 'WC'])
@@ -264,7 +264,7 @@ class VertimusTest(TestCase):
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
- self.assertEqual(action_names, ['BA', 'WC', None, 'IC'])
+ self.assertEqual(action_names, ['AA', 'WC', None, 'IC'])
def test_action_wc(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='None').get_state()
@@ -358,10 +358,10 @@ class VertimusTest(TestCase):
self.assert_(not os.access(file_path, os.F_OK))
# Remove test file
- backup_action = ActionDbBackup.objects.get(comment="Done.")
- backup_file_path = os.path.join(settings.MEDIA_ROOT, backup_action.file.name)
- backup_action.delete()
- self.assert_(not os.access(backup_file_path, os.F_OK))
+ action_db_archived = ActionDbArchived.objects.get(comment="Done.")
+ filename_archived = os.path.join(settings.MEDIA_ROOT, action_db_archived.file.name)
+ action_db_archived.delete()
+ self.assert_(not os.access(filename_archived, os.F_OK))
def test_action_tr(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Translated').get_state()
@@ -375,7 +375,7 @@ class VertimusTest(TestCase):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Committed', person=self.pr).get_state()
state.save()
- action = ActionAbstract.new_by_name('BA')
+ action = ActionAbstract.new_by_name('AA')
state = state.apply_action(action, self.pc, comment="I don't want to disappear :)")
state.save()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]