|
|
|
@ -33,7 +33,11 @@ def upload_to(path, new_filename=None): |
|
|
|
"""Куда и под каким именем сохранить загруженный файл.""" |
|
|
|
"""Куда и под каким именем сохранить загруженный файл.""" |
|
|
|
def get_upload_path(instance, filename): |
|
|
|
def get_upload_path(instance, filename): |
|
|
|
filename = new_filename or filename |
|
|
|
filename = new_filename or filename |
|
|
|
return os.path.join(path, instance.user.username, filename) |
|
|
|
try: |
|
|
|
|
|
|
|
profile_dir = instance.get_first_user().username |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
profile_dir = 'NoUser' |
|
|
|
|
|
|
|
return os.path.join(path, profile_dir, filename) |
|
|
|
return get_upload_path |
|
|
|
return get_upload_path |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -157,7 +161,14 @@ class UserProfile(models.Model): |
|
|
|
|
|
|
|
|
|
|
|
def get_main_bank_account(self): |
|
|
|
def get_main_bank_account(self): |
|
|
|
try: |
|
|
|
try: |
|
|
|
bank_accounts = BankAccount.objects.filter(company=self.user.profile, is_main=True)[0] |
|
|
|
bank_accounts = BankAccount.objects.filter(company=self, is_main=True)[0] |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_first_user(self): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
first_user = DokUser.objects.filter(profile=self) |
|
|
|
|
|
|
|
return first_user |
|
|
|
except: |
|
|
|
except: |
|
|
|
return None |
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|