@@ -395,16 +395,13 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): |
||
395 | 395 |
@property |
396 | 396 |
def srinfo(self): |
397 | 397 |
try: |
398 |
- sr = SalesResponsibilityInfo.objects.get(user_id=self.user_id) |
|
398 |
+ sr = SalesResponsibilityInfo.objects.get(user_id=self.user_id, user_status=SalesResponsibilityInfo.ACTIVATED) |
|
399 | 399 |
except SalesResponsibilityInfo.DoesNotExist: |
400 | 400 |
sr = None |
401 |
- sr_id = sr.sr_id if sr and sr.user_status == SalesResponsibilityInfo.ACTIVATED else '' |
|
402 |
- is_sr = True if sr and sr.user_status == SalesResponsibilityInfo.ACTIVATED else False |
|
403 |
- is_super_sr = True if sr and sr.is_super else False |
|
404 |
- return { |
|
405 |
- 'sr_id': sr_id, |
|
406 |
- 'is_sr': is_sr, |
|
407 |
- 'is_super_sr': is_super_sr, |
|
401 |
+ return sr.base_data if sr else { |
|
402 |
+ 'sr_id': '', |
|
403 |
+ 'is_sr': False, |
|
404 |
+ 'is_super_sr': False, |
|
408 | 405 |
} |
409 | 406 |
|
410 | 407 |
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, |