def get_settings_based_on_user(self, loggedin): self = UserSettings.objects.filter(UserAccount=loggedin).first() if self is None: # We will create a new instance of user settings (probably first time log in) self = UserSettings() self.UserAccount = loggedin BaseCurrency = Currency() BaseCurrency.IdCurrency = Currency._meta.get_field( 'IdCurrency').get_default() BaseCurrency.Country = Currency._meta.get_field( 'Country').get_default() BaseCurrency.Name = Currency._meta.get_field('Name').get_default() BaseCurrency.Code = Currency._meta.get_field('Code').get_default() self.BaseCountry = Country() self.BaseCountry.IdCountry = Country._meta.get_field( 'IdCountry').get_default() self.BaseCountry.Name = Country._meta.get_field( 'Name').get_default() self.BaseCountry.Code = Country._meta.get_field( 'Code').get_default() self.BaseCountry.PrimaryCurrency = BaseCurrency self.PaymentLevel = 's' self.UrlSlug = self.generate_slug_for_new_user(loggedin) super(UserSettings, self).save() # In the rare even a slug wasn't created because of much older users, I rather just have the server side code handle it here if self.UrlSlug == "": self.UrlSlug = self.generate_slug_for_new_user(loggedin) super(UserSettings, self).save() return self
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() kenny = User.objects.create(username="******", email="*****@*****.**", first_name="Kenny", last_name="Kim") kenny.set_password("Thing5Ar3Gr34t") kenny.save() clara = User.objects.create(username="******", email="*****@*****.**", first_name="Clara", last_name="Chang") clara.set_password("Thing5Ar3Gr34t") clara.save() settings_kenny = UserSettings() settings_kenny = settings_kenny.get_settings_based_on_user(kenny) settings_kenny.save() settings_clara = UserSettings() settings_clara = settings_clara.get_settings_based_on_user(clara) settings_clara.BusinessName = "InFlow" settings_clara.Region = "New York" settings_clara.PhoneNumber = "2125555555" settings_clara.StripeConnectAccountKey = "1234567890" settings_clara.save()
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Types u1 = UserType.objects.create(Name="Clara Type 1") u2 = UserType.objects.create(Name="Clara Type 2") u3 = UserType.objects.create(Name="Clara Type 3") clara = User.objects.create( username="******", email="*****@*****.**", first_name="Clara", last_name="Chang") # Has User Settings, no associated types clara.set_password("Thing5Ar3Gr34t") clara.save() settings_clara = UserSettings() settings_clara = settings_clara.get_settings_based_on_user(clara) settings_clara.BusinessName = "InFlow" settings_clara.Region = "New York" settings_clara.save()
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Types u1 = UserType.objects.create(Name="Kenny Type 1") u2 = UserType.objects.create(Name="Kenny Type 2") u3 = UserType.objects.create(Name="Kenny Type 3") kenny = User.objects.create( username="******", email="*****@*****.**", first_name="Kenny", last_name="Kim" ) # Has User Settings, has associated types, neither of the two fields we check kenny.set_password("Thing5Ar3Gr34t") kenny.save() settings_kenny = UserSettings() settings_kenny = settings_kenny.get_settings_based_on_user(kenny) settings_kenny.save() UserAssociatedTypes.objects.create(UserAccount=kenny, UserFreelanceType=u2) UserAssociatedTypes.objects.create(UserAccount=kenny, UserFreelanceType=u3)
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Types u1 = UserType.objects.create(Name="Type 1") u2 = UserType.objects.create(Name="Type 2") u3 = UserType.objects.create(Name="Type 3") brian = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") # Passes settings_brian = UserSettings() settings_brian = settings_brian.get_settings_based_on_user(brian) settings_brian.BusinessName = "MIAC" settings_brian.Region = "New York" settings_brian.save() UserAssociatedTypes.objects.create(UserAccount=brian, UserFreelanceType=u1) josh = User.objects.create(username="******", email="*****@*****.**", first_name="Josh", last_name="Blank") # No User Settings kenny = User.objects.create( username="******", email="*****@*****.**", first_name="Kenny", last_name="Kim" ) # Has User Settings, has associated types, neither of the two fields we check kenny.set_password("Thing5Ar3Gr34t") kenny.save() settings_kenny = UserSettings() settings_kenny = settings_brian.get_settings_based_on_user(kenny) settings_kenny.save() UserAssociatedTypes.objects.create(UserAccount=kenny, UserFreelanceType=u2) UserAssociatedTypes.objects.create(UserAccount=kenny, UserFreelanceType=u3) clara = User.objects.create( username="******", email="*****@*****.**", first_name="Clara", last_name="Chang") # Has User Settings, no associated types clara.set_password("Thing5Ar3Gr34t") clara.save() settings_clara = UserSettings() settings_clara = settings_brian.get_settings_based_on_user(clara) settings_clara.BusinessName = "InFlow" settings_clara.Region = "New York" settings_clara.save()
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Brian - User 1 brian = User.objects.create(username="******", email="*****@*****.**", password="******", first_name="Brian", last_name="Katchmar", is_staff=True, is_active=True, is_superuser=True) brian.set_password("th3l10nK1ng15Fun") brian.save() # Kenny - User 2 kenny = User.objects.create(username="******", email="*****@*****.**", password="******", first_name="Kenny", last_name="Kim", is_staff=True, is_active=True, is_superuser=True) kenny.set_password("th3l10nK1ng15Funner") kenny.save()
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Users user_1 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") user_1.set_password("Th3L10nK1ng15Fun") user_1.save() settings_user_1 = UserSettings() settings_user_1 = settings_user_1.get_settings_based_on_user(user_1) settings_user_1.BusinessName = "MIAC" settings_user_1.Region = "New York" settings_user_1.save() user_2 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") user_2.set_password("Thing5Ar3Gr34t") user_2.save() settings_user_2 = UserSettings() settings_user_2 = settings_user_2.get_settings_based_on_user(user_2) settings_user_2.save() user_3 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") user_3.set_password("Thing5Ar3Gr34t") user_3.save() settings_user_3 = UserSettings() settings_user_3 = settings_user_3.get_settings_based_on_user(user_3) settings_user_3.BusinessName = "InFlow" settings_user_3.Region = "New York" settings_user_3.PhoneNumber = "2125555555" settings_user_3.StripeConnectAccountKey = "1234567890" settings_user_3.save()
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Users brian_1 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") brian_1.set_password("Th3L10nK1ng15Fun") brian_1.save() settings_brian_1 = UserSettings() settings_brian_1 = settings_brian_1.get_settings_based_on_user(brian_1) settings_brian_1.save() brian_2 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") brian_2.set_password("Th3L10nK1ng15Fun") brian_2.save() settings_brian_2 = UserSettings() settings_brian_2 = settings_brian_2.get_settings_based_on_user(brian_2) settings_brian_2.save() if not Contract.objects.filter(Name=self.contract_name_1).exists(): contract_1 = Contract.objects.create(Creator=brian_1, Name=self.contract_name_1, StartDate=date.today(), EndDate=date.today()) Relationship.objects.create(ContractUser=brian_1, ContractForRelationship=contract_1, RelationshipType="f") Relationship.objects.create(ContractUser=brian_2, ContractForRelationship=contract_1, RelationshipType="c")
def setUp(self): usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() testUser = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar", is_staff=True, is_active=True, is_superuser=True) testUser.set_password("ilikechickenfingersandpizza") testUser.save()
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Users brian_1 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") brian_1.set_password("Th3L10nK1ng15Fun") brian_1.save() brian_2 = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") brian_2.set_password("Th3L10nK1ng15Fun") brian_2.save()
def setUp(self): usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() brianUser = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar", is_staff=False, is_active=True, is_superuser=False) brianUser.set_password("ilikechickenfingersandpizza") brianUser.save() if not Contract.objects.filter(Name=self.test_contract_name).exists(): contract_1 = Contract.objects.create(Creator=brianUser, Name=self.test_contract_name, StartDate=date.today(), EndDate=date.today()) contract_1.create_slug() contract_1.save() Relationship.objects.create(ContractUser=brianUser, ContractForRelationship=contract_1, RelationshipType='f') Recipient.objects.create(ContractForRecipient=contract_1, Name="Snickity Snack", BillingName="Billing Things INC", PhoneNumber="1243", EmailAddress="*****@*****.**")
def setUp(self): # Necessary Currency Objects usd = Currency.objects.create() USA = Country() USA.PrimaryCurrency = usd USA.Name = "United States" USA.Code = "US" USA.save() # Users brian = User.objects.create(username="******", email="*****@*****.**", first_name="Brian", last_name="Katchmar") brian.set_password("Th3L10nK1ng15Fun") brian.save() settings_brian = UserSettings() settings_brian = settings_brian.get_settings_based_on_user(brian) settings_brian.BusinessName = "MIAC" settings_brian.Region = "New York" settings_brian.save() kenny = User.objects.create( username="******", email="*****@*****.**", first_name="Kenny", last_name="Kim" ) # Has User Settings, has associated types, neither of the two fields we check kenny.set_password("Thing5Ar3Gr34t") kenny.save() settings_kenny = UserSettings() settings_kenny = settings_kenny.get_settings_based_on_user(kenny) settings_kenny.save() clara = User.objects.create(username="******", email="*****@*****.**", first_name="Clara", last_name="Chang") clara.set_password("Thing5Ar3Gr34t") clara.save() settings_clara = UserSettings() settings_clara = settings_clara.get_settings_based_on_user(clara) settings_clara.BusinessName = "InFlow" settings_clara.Region = "New York" settings_clara.PhoneNumber = "2125555555" settings_clara.StripeConnectAccountKey = "1234567890" settings_clara.save() if NotificationSetting.objects.filter( SettingName=self.setting_string_1).exists(): ns1 = NotificationSetting.objects.get( SettingName=self.setting_string_1) else: ns1 = NotificationSetting.objects.create( SettingName=self.setting_string_1) if NotificationSetting.objects.filter( SettingName=self.setting_string_2).exists(): ns2 = NotificationSetting.objects.get( SettingName=self.setting_string_2) else: ns2 = NotificationSetting.objects.create( SettingName=self.setting_string_2) if NotificationSetting.objects.filter( SettingName=self.setting_string_3).exists(): ns3 = NotificationSetting.objects.get( SettingName=self.setting_string_3) else: ns3 = NotificationSetting.objects.create( SettingName=self.setting_string_3) if NotificationSetting.objects.filter( SettingName=self.setting_string_4).exists(): ns4 = NotificationSetting.objects.get( SettingName=self.setting_string_4) else: ns4 = NotificationSetting.objects.create( SettingName=self.setting_string_4) # Purge the DB Entries, we're rebuild what we're expecting UserNotificationSettings.objects.filter(UserAccount=brian).delete() UserNotificationSettings.objects.filter(UserAccount=kenny).delete() UserNotificationSettings.objects.filter(UserAccount=clara).delete() # Brian UserNotificationSettings.objects.create(UserAccount=brian, Setting=ns1, Selected=True) UserNotificationSettings.objects.create(UserAccount=brian, Setting=ns2, Selected=True) UserNotificationSettings.objects.create(UserAccount=brian, Setting=ns3, Selected=True) UserNotificationSettings.objects.create(UserAccount=brian, Setting=ns4, Selected=True) # Kenny UserNotificationSettings.objects.create(UserAccount=kenny, Setting=ns1, Selected=True) UserNotificationSettings.objects.create(UserAccount=kenny, Setting=ns2, Selected=False) UserNotificationSettings.objects.create(UserAccount=kenny, Setting=ns3, Selected=False) UserNotificationSettings.objects.create(UserAccount=kenny, Setting=ns4, Selected=True) # Clara UserNotificationSettings.objects.create(UserAccount=clara, Setting=ns1, Selected=False) UserNotificationSettings.objects.create(UserAccount=clara, Setting=ns2, Selected=True) UserNotificationSettings.objects.create(UserAccount=clara, Setting=ns3, Selected=False) UserNotificationSettings.objects.create(UserAccount=clara, Setting=ns4, Selected=True)