@@ -387,16 +387,13 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
| 387 | 387 |
@property |
| 388 | 388 |
def srinfo(self): |
| 389 | 389 |
try: |
| 390 |
- sr = SalesResponsibilityInfo.objects.get(user_id=self.user_id) |
|
| 390 |
+ sr = SalesResponsibilityInfo.objects.get(user_id=self.user_id, user_status=SalesResponsibilityInfo.ACTIVATED) |
|
| 391 | 391 |
except SalesResponsibilityInfo.DoesNotExist: |
| 392 | 392 |
sr = None |
| 393 |
- sr_id = sr.sr_id if sr and sr.user_status == SalesResponsibilityInfo.ACTIVATED else '' |
|
| 394 |
- is_sr = True if sr and sr.user_status == SalesResponsibilityInfo.ACTIVATED else False |
|
| 395 |
- is_super_sr = True if sr and sr.is_super else False |
|
| 396 |
- return {
|
|
| 397 |
- 'sr_id': sr_id, |
|
| 398 |
- 'is_sr': is_sr, |
|
| 399 |
- 'is_super_sr': is_super_sr, |
|
| 393 |
+ return sr.base_data if sr else {
|
|
| 394 |
+ 'sr_id': '', |
|
| 395 |
+ 'is_sr': False, |
|
| 396 |
+ 'is_super_sr': False, |
|
| 400 | 397 |
} |
| 401 | 398 |
|
| 402 | 399 |
def brandata(self, brand_id=None): |
@@ -54,6 +54,14 @@ class SalesResponsibilityInfo(BaseModelMixin): |
||
| 54 | 54 |
return u'{}-{}'.format(self.name, self.phone)
|
| 55 | 55 |
|
| 56 | 56 |
@property |
| 57 |
+ def base_data(self): |
|
| 58 |
+ return {
|
|
| 59 |
+ 'sr_id': self.sr_id, |
|
| 60 |
+ 'is_sr': True, |
|
| 61 |
+ 'is_super': self.is_super, |
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ @property |
|
| 57 | 65 |
def admindata(self): |
| 58 | 66 |
return {
|
| 59 | 67 |
'brand_id': self.brand_id, |