# Path: baobab/translate/models.py
# class EventData(models.Model):
# 
#     event = models.ForeignKey('backoffice.Event', related_name='eventdatas')
#     lang = models.ForeignKey('Lang', related_name='eventdatas')
#     title = models.CharField(max_length=255,
#                              help_text='A short description of the event')
#     summary = models.TextField(null=True, blank=True, default=None)
#     user = models.ForeignKey(User, related_name='eventdatas', null=True,
#                              default=None)
# 
#     class Meta:
#         unique_together = ('event', 'lang')
# 
# class EventLogData(models.Model):
# 
#     eventlog = models.ForeignKey('backoffice.EventLog',
#                                  related_name='eventlogdatas')
#     lang = models.ForeignKey('Lang', related_name='eventlogdatas')
#     comment = models.TextField()
#     user = models.ForeignKey(User, related_name='eventlogdatas', null=True,
#                              default=None)
# 
#     class Meta:
#         unique_together = ('eventlog', 'lang')
# 
# class Lang(models.Model):
# 
#     name = models.CharField(max_length=200, unique=True)
#     iso = models.CharField(max_length=5, unique=True)
# 
#     def __unicode__(self):
#         return self.name
# 
# Path: baobab/backoffice/models.py
# class Event(models.Model):
#     objects = EventManager()  # override the default manager
# 
#     # Used for <pubDate> in RSS Feed
#     last_update = models.DateTimeField(default=now)
# 
#     date_start = models.DateTimeField(default=now)
#     date_end = models.DateTimeField(null=True, blank=True, default=None)
#     estimate_date_end = models.DateTimeField()
#     duration = models.PositiveIntegerField(help_text='Duration (in minutes)')
# 
#     # XXX to remove at the next release
#     title = models.CharField(max_length=255,
#                              help_text='A short description of the event')
# 
#     # XXX to remove at the next release
#     summary = models.TextField(null=True, blank=True, default=None)
#     services = models.ManyToManyField('Service', related_name='events',
#                                       blank=True)
#     MAINTENANCE = 0
#     INCIDENT = 1
#     CATEGORY_CHOICES = (
#         (MAINTENANCE, 'Maintenance'),
#         (INCIDENT, 'Incident'),
#     )
#     category = models.PositiveSmallIntegerField(choices=CATEGORY_CHOICES,
#                                                 help_text='Type of the Event')
#     msg = models.CharField('Social Network', max_length=255,
#                            null=True, blank=True, default=None)
# 
#     def __unicode__(self):
#         return self.title
# 
#     def save(self, *args, **kwargs):
#         if not self.id and self.date_end and self.date_end > now():
#             # create an event with a date_end in future: need to be converted
#             # to the estimate_date_end
#             delta = self.date_end - self.date_start
#             self.duration = delta.total_seconds() / 60
#             self.date_end = None
#         if self.date_end:
#             delta = self.date_end - self.date_start
#             self.duration = delta.total_seconds() / 60
#             if not self.estimate_date_end or \
#                self.date_start >= self.estimate_date_end:
#                 self.estimate_date_end = self.date_end
#             if self.date_end <= now():
#                 if self.eventlogs.exists() and \
#                    self.eventlogs.all()[0].date < self.date_end:
#                     self.last_update = self.date_end
#         else:
#             delta = timedelta(minutes=self.duration)
#             self.estimate_date_end = self.date_start + delta
#         super(Event, self).save(*args, **kwargs)
# 
#     class Meta:
#         # XXX avoid the admin to override the right order: see EventQuerySet
#         ordering = ['id', 'pk']
# 
# class EventLog(models.Model):
#     date = models.DateTimeField(default=now)
# 
#     # XXX to remove at the next release
#     comment = models.TextField()
# 
#     event = models.ForeignKey('Event', related_name='eventlogs')
#     user = models.ForeignKey(User, related_name='eventlogs')
#     msg = models.CharField('Social Network', max_length=255,
#                            null=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         super(EventLog, self).save(*args, **kwargs)
#         self.event.last_update = self.date
#         self.event.save()
# 
#     class Meta:
#         ordering = ['-date', ]


import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from django.contrib.auth.models import Group, Permission
from baobab.translate.models import EventData, EventLogData, Lang
from baobab.backoffice.models import Event, EventLog
            {'name': 'Spanish', 'iso': 'es'},
            {'name': 'Simplified Chinese', 'iso': 'zh-SG'},
            {'name': 'Translate Chinese', 'iso': 'zh-TW'},
        ]
        for lang in langs:
            Lang.objects.create(**lang)
        en = Lang.objects.get(name='English')
        for event in Event.objects.all():
            user = None
            if event.eventlogs.exists():
                user = event.eventlogs.order_by('date')[0].user
            EventData.objects.create(
                event=event,
                title=event.title,
                summary=event.summary,
                lang=en,
                user=user
            )
        for eventlog in EventLog.objects.all():
            EventLogData.objects.create(
                eventlog=eventlog,
                comment=eventlog.comment,
                user=eventlog.user,
                lang=en
            )
        rights = Permission.objects.filter(content_type__app_label='translate')
        Group.objects.create(name='translate').permissions.add(*rights)

    def backwards(self, orm):
        en = Lang.objects.get(name='English')

# Path: baobab/translate/models.py
# class EventData(models.Model):
# 
#     event = models.ForeignKey('backoffice.Event', related_name='eventdatas')
#     lang = models.ForeignKey('Lang', related_name='eventdatas')
#     title = models.CharField(max_length=255,
#                              help_text='A short description of the event')
#     summary = models.TextField(null=True, blank=True, default=None)
#     user = models.ForeignKey(User, related_name='eventdatas', null=True,
#                              default=None)
# 
#     class Meta:
#         unique_together = ('event', 'lang')
# 
# class EventLogData(models.Model):
# 
#     eventlog = models.ForeignKey('backoffice.EventLog',
#                                  related_name='eventlogdatas')
#     lang = models.ForeignKey('Lang', related_name='eventlogdatas')
#     comment = models.TextField()
#     user = models.ForeignKey(User, related_name='eventlogdatas', null=True,
#                              default=None)
# 
#     class Meta:
#         unique_together = ('eventlog', 'lang')
# 
# class Lang(models.Model):
# 
#     name = models.CharField(max_length=200, unique=True)
#     iso = models.CharField(max_length=5, unique=True)
# 
#     def __unicode__(self):
#         return self.name
# 
# Path: baobab/backoffice/models.py
# class Event(models.Model):
#     objects = EventManager()  # override the default manager
# 
#     # Used for <pubDate> in RSS Feed
#     last_update = models.DateTimeField(default=now)
# 
#     date_start = models.DateTimeField(default=now)
#     date_end = models.DateTimeField(null=True, blank=True, default=None)
#     estimate_date_end = models.DateTimeField()
#     duration = models.PositiveIntegerField(help_text='Duration (in minutes)')
# 
#     # XXX to remove at the next release
#     title = models.CharField(max_length=255,
#                              help_text='A short description of the event')
# 
#     # XXX to remove at the next release
#     summary = models.TextField(null=True, blank=True, default=None)
#     services = models.ManyToManyField('Service', related_name='events',
#                                       blank=True)
#     MAINTENANCE = 0
#     INCIDENT = 1
#     CATEGORY_CHOICES = (
#         (MAINTENANCE, 'Maintenance'),
#         (INCIDENT, 'Incident'),
#     )
#     category = models.PositiveSmallIntegerField(choices=CATEGORY_CHOICES,
#                                                 help_text='Type of the Event')
#     msg = models.CharField('Social Network', max_length=255,
#                            null=True, blank=True, default=None)
# 
#     def __unicode__(self):
#         return self.title
# 
#     def save(self, *args, **kwargs):
#         if not self.id and self.date_end and self.date_end > now():
#             # create an event with a date_end in future: need to be converted
#             # to the estimate_date_end
#             delta = self.date_end - self.date_start
#             self.duration = delta.total_seconds() / 60
#             self.date_end = None
#         if self.date_end:
#             delta = self.date_end - self.date_start
#             self.duration = delta.total_seconds() / 60
#             if not self.estimate_date_end or \
#                self.date_start >= self.estimate_date_end:
#                 self.estimate_date_end = self.date_end
#             if self.date_end <= now():
#                 if self.eventlogs.exists() and \
#                    self.eventlogs.all()[0].date < self.date_end:
#                     self.last_update = self.date_end
#         else:
#             delta = timedelta(minutes=self.duration)
#             self.estimate_date_end = self.date_start + delta
#         super(Event, self).save(*args, **kwargs)
# 
#     class Meta:
#         # XXX avoid the admin to override the right order: see EventQuerySet
#         ordering = ['id', 'pk']
# 
# class EventLog(models.Model):
#     date = models.DateTimeField(default=now)
# 
#     # XXX to remove at the next release
#     comment = models.TextField()
# 
#     event = models.ForeignKey('Event', related_name='eventlogs')
#     user = models.ForeignKey(User, related_name='eventlogs')
#     msg = models.CharField('Social Network', max_length=255,
#                            null=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         super(EventLog, self).save(*args, **kwargs)
#         self.event.last_update = self.date
#         self.event.save()
# 
#     class Meta:
#         ordering = ['-date', ]


# Path: baobab/translate/migrations/0002_set_traduction.py
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from django.contrib.auth.models import Group, Permission
from baobab.translate.models import EventData, EventLogData, Lang
from baobab.backoffice.models import Event, EventLog

            {'name': 'Spanish', 'iso': 'es'},
            {'name': 'Simplified Chinese', 'iso': 'zh-SG'},
            {'name': 'Translate Chinese', 'iso': 'zh-TW'},
        ]
        for lang in langs:
            Lang.objects.create(**lang)
        en = Lang.objects.get(name='English')
        for event in Event.objects.all():
            user = None
            if event.eventlogs.exists():
                user = event.eventlogs.order_by('date')[0].user
            EventData.objects.create(
                event=event,
                title=event.title,
                summary=event.summary,
                lang=en,
                user=user
            )
        for eventlog in EventLog.objects.all():
            EventLogData.objects.create(
                eventlog=eventlog,
                comment=eventlog.comment,
                user=eventlog.user,
                lang=en
            )
        rights = Permission.objects.filter(content_type__app_label='translate')
        Group.objects.create(name='translate').permissions.add(*rights)

    def backwards(self, orm):
        en = Lang.objects.get(name='English')

        for eventdata in EventData.objects.filter(lang=en):