From ce705c3cef767803700629d9598a2ebaff14687d Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 29 Feb 2016 12:16:09 +0200 Subject: Added timezone field for GSX accounts To simplify connections (no need for location or user account) --- servo/migrations/0049_gsxaccount_timezone.py | 20 +++++++++++++++++++ servo/models/common.py | 29 +++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 servo/migrations/0049_gsxaccount_timezone.py (limited to 'servo') diff --git a/servo/migrations/0049_gsxaccount_timezone.py b/servo/migrations/0049_gsxaccount_timezone.py new file mode 100644 index 0000000..746a0e1 --- /dev/null +++ b/servo/migrations/0049_gsxaccount_timezone.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2016-02-29 09:13 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('servo', '0048_auto_20160225_2328'), + ] + + operations = [ + migrations.AddField( + model_name='gsxaccount', + name='timezone', + field=models.CharField(choices=[(b'PST', b'UTC - 8h (Pacific Standard Time)'), (b'PDT', b'UTC - 7h (Pacific Daylight Time)'), (b'CST', b'UTC - 6h (Central Standard Time)'), (b'CDT', b'UTC - 5h (Central Daylight Time)'), (b'EST', b'UTC - 5h (Eastern Standard Time)'), (b'EDT', b'UTC - 4h (Eastern Daylight Time)'), (b'GMT', b'UTC (Greenwich Mean Time)'), (b'CET', b'UTC + 1h (Central European Time)'), (b'CEST', b'UTC + 2h (Central European Summer Time)'), (b'USZ1', b'UTC + 3h (Kaliningrad Time)'), (b'MSK', b'UTC + 4h (Moscow Time)'), (b'IST', b'UTC + 5.5h (Indian Standard Time)'), (b'YEKST', b'UTC + 6h (Yekaterinburg Time)'), (b'OMSST', b'UTC + 7h (Omsk Time)'), (b'KRAST', b'UTC + 8h (Krasnoyarsk Time)'), (b'CCT', b'UTC + 8h (Chinese Coast Time)'), (b'IRKST', b'UTC + 9h (Irkutsk Time)'), (b'JST', b'UTC + 9h (Japan Standard Time)'), (b'YAKST', b'UTC + 10h (Yakutsk Time)'), (b'AEST', b'UTC + 10h (Australian Eastern Standard Time)'), (b'VLAST', b'UTC + 11h (Vladivostok Time)'), (b'AEDT', b'UTC + 11h (Australian Eastern Daylight Time)'), (b'ACST', b'UTC + 9.5h (Austrailian Central Standard Time)'), (b'ACDT', b'UTC + 10.5h (Australian Central Daylight Time)'), (b'NZST', b'UTC + 12h (New Zealand Standard Time)'), (b'MAGST', b'UTC + 12h (Magadan Time)')], default=b'CEST', max_length=4, verbose_name='Timezone'), + ), + ] diff --git a/servo/models/common.py b/servo/models/common.py index 4ca1ff8..4d91296 100644 --- a/servo/models/common.py +++ b/servo/models/common.py @@ -182,17 +182,24 @@ class GsxAccount(models.Model): sold_to = models.CharField(max_length=10, verbose_name=_("Sold-To")) ship_to = models.CharField(max_length=10, verbose_name=_("Ship-To")) + user_id = models.CharField( + blank=True, + default='', + max_length=128, + verbose_name=_("User ID") + ) + region = models.CharField( max_length=3, choices=gsxws.GSX_REGIONS, verbose_name=_("Region") ) - user_id = models.CharField( - blank=True, - default='', - max_length=128, - verbose_name=_("User ID") + timezone = models.CharField( + max_length=4, + default='CEST', + verbose_name=_('Timezone'), + choices=gsxws.GSX_TIMEZONES ) environment = models.CharField( @@ -239,6 +246,18 @@ class GsxAccount(models.Model): return act + @classmethod + def fallback(cls): + """ + Connect to fallback GSX account + """ + act = cls.get_default_account() + gsxws.connect(user_id=act.user_id, + sold_to=act.sold_to, + timezone=act.timezone, + environment=act.environment,) + return act + @classmethod def default(cls, user, queue=None): """ -- cgit v1.2.3