1
from django.utils.translation import ugettext
3
from events.models import TeamEvent
5
def merge_teams(old_team, new_team):
7
related_events = TeamEvent.objects.filter(teams__id=old_team.id)
8
for event in related_events:
9
for team in event.teams.filter(id=old_team.id):
10
msgs += [ugettext('New owner of event "%s" is team "%s".' % (event.name, new_team.name))]
11
event.teams.remove(team)
12
event.teams.add(new_team)
14
if old_team.contact_profiles.count() and not new_team.contact_profiles.count():
15
for contact_profile in old_team.contact_profiles.all():
16
new_team.contact_profiles.add(contact_profile)
17
msgs += [ugettext('Adding contact "%s" to team "%s".' % (contact_profile.realname, new_team.name))]
18
if old_team.countries.count() and not new_team.countries.count():
19
for country in old_team.countries.all():
20
new_team.countries.add(country)
21
msgs += [ugettext('Adding country "%s" to team "%s".' % (country.name, new_team.name))]
22
if old_team.languages.count() and not new_team.languages.count():
23
for language in old_team.languages.all():
24
new_team.languages.add(language)
25
msgs += [ugettext('Adding language "%s" to team "%s".' % (language.name, new_team.name))]
26
if old_team.spr and not new_team.spr:
27
new_team.spr = old_team.spr
28
msgs += [ugettext('Setting State/Province/Region of "%s" to "%s".' % (new_team.name, old_team.spr))]
29
if old_team.city and not new_team.city:
30
new_team.city = old_team.city
31
msgs += [ugettext('Setting city of "%s" to "%s".' % (new_team.name, old_team.city))]
32
if old_team.wiki_url and not new_team.wiki_url:
33
new_team.wiki_url = old_team.wiki_url
34
msgs += [ugettext('Setting Wiki URL of "%s" to "%s".' % (new_team.name, old_team.wiki_url))]
35
if old_team.web_url and not new_team.web_url:
36
new_team.web_url = old_team.web_url
37
msgs += [ugettext('Setting Web URL of "%s" to "%s".' % (new_team.name, old_team.web_url))]
38
if old_team.ml_url and not new_team.ml_url:
39
new_team.ml_url = old_team.ml_url
40
msgs += [ugettext('Setting Mailing list URL of "%s" to "%s".' % (new_team.name, old_team.ml_url))]
41
if old_team.forum_url and not new_team.forum_url:
42
new_team.forum_url = old_team.forum_url
43
msgs += [ugettext('Setting Forum URL of "%s" to "%s".' % (new_team.name, old_team.forum_url))]
44
if old_team.email and not new_team.email:
45
new_team.email = old_team.email
46
msgs += [ugettext('Setting email address of "%s" to "%s".' % (new_team.name, old_team.email))]
47
if old_team.irc_chan and not new_team.irc_chan:
48
new_team.irc_chane = old_team.irc_chan
49
msgs += [ugettext('Setting IRC channel of "%s" to "%s".' % (new_team.name, old_team.irc_chan))]
50
if old_team.flickr_id and not new_team.flickr_id:
51
new_team.flickr_id = old_team.flickr_id
52
msgs += [ugettext('Setting Flickr ID of "%s" to "%s".' % (new_team.name, old_team.flickr_id))]
53
if old_team.picasa_id and not new_team.picasa_id:
54
new_team.picasa_id = old_team.picasa_id
55
msgs += [ugettext('Setting Picasa ID of "%s" to "%s".' % (new_team.name, old_team.picasa_id))]
56
if old_team.pixie_id and not new_team.pixie_id:
57
new_team.pixie_id = old_team.pixie_id
58
msgs += [ugettext('Setting Pix.ie ID of "%s" to "%s".' % (new_team.name, old_team.pixie_id))]
61
msgs += [ugettext('Team "%s" merged with "%s".' % (old_team.name, new_team.name))]