Skip to content

Commit

Permalink
get username form header
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Mar 31, 2019
1 parent 97a9d61 commit 513ca24
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
3 changes: 2 additions & 1 deletion apps/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def post(self, request, *args, **kwargs):
app_name = request_data_dict.get('app_name', '')
ticket_sn_prefix = request_data_dict.get('ticket_sn_prefix', '')
workflow_ids = request_data_dict.get('workflow_ids', '')
username = request.user.username
# username = request.user.username
username = request.META.get('HTTP_USERNAME')
flag, msg = AccountBaseService().add_token_record(app_name, ticket_sn_prefix, workflow_ids, username)
if flag is False:
code, data = -1, {}
Expand Down
18 changes: 12 additions & 6 deletions apps/ticket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def get(self, request, *args, **kwargs):
request_data = request.GET
sn = request_data.get('sn', '')
title = request_data.get('title', '')
username = request_data.get('username', '')
# username = request_data.get('username', '')
username = request.META.get('HTTP_USERNAME')
create_start = request_data.get('create_start', '')
create_end = request_data.get('create_end', '')
workflow_ids = request_data.get('workflow_ids', '')
Expand Down Expand Up @@ -88,7 +89,8 @@ def get(self, request, *args, **kwargs):
if not app_permission_check:
return api_response(-1, msg, '')

username = request_data.get('username', '')
# username = request_data.get('username', '')
username = request.META.get('HTTP_USERNAME')
if not username:
return api_response(-1, '参数不全,请提供username', '')
result, msg = TicketBaseService.get_ticket_detail(ticket_id, username)
Expand Down Expand Up @@ -133,7 +135,8 @@ class TicketTransition(View):
def get(self, request, *args, **kwargs):
request_data = request.GET
ticket_id = kwargs.get('ticket_id')
username = request_data.get('username', '')
# username = request_data.get('username', '')
username = request.META.get('HTTP_USERNAME')
from service.account.account_base_service import AccountBaseService
app_name = request.META.get('HTTP_APPNAME')
app_permission_check, msg = AccountBaseService.app_ticket_permission_check(app_name, ticket_id)
Expand All @@ -157,7 +160,8 @@ class TicketFlowlog(View):
def get(self, request, *args, **kwargs):
request_data = request.GET
ticket_id = kwargs.get('ticket_id')
username = request_data.get('username', '') # 可用于权限控制
# username = request_data.get('username', '') # 可用于权限控制
username = request.META.get('HTTP_USERNAME')
per_page = int(request_data.get('per_page', 10))
page = int(request_data.get('page', 1))
from service.account.account_base_service import AccountBaseService
Expand Down Expand Up @@ -186,7 +190,8 @@ class TicketFlowStep(View):
def get(self, request, *args, **kwargs):
request_data = request.GET
ticket_id = kwargs.get('ticket_id')
username = request_data.get('username', '') # 可用于权限控制
# username = request_data.get('username', '') # 可用于权限控制
username = request.META.get('HTTP_USERNAME')

from service.account.account_base_service import AccountBaseService
app_name = request.META.get('HTTP_APPNAME')
Expand Down Expand Up @@ -255,7 +260,8 @@ def get(self, request, *args, **kwargs):
:return:
"""
request_data = request.GET
username = request_data.get('username', '') # 可用于权限控制
# username = request_data.get('username', '') # 可用于权限控制
username = request.META.get('HTTP_USERNAME')
ticket_ids = request_data.get('ticket_ids') # 逗号隔开
ticket_id_list = ticket_ids.split(',')
ticket_id_list = [int(ticket_id) for ticket_id in ticket_id_list]
Expand Down
21 changes: 14 additions & 7 deletions apps/workflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def get(self, request, *args, **kwargs):
name = request_data.get('name', '')
per_page = int(request_data.get('per_page', 10))
page = int(request_data.get('page', 1))
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')
app_name = request.META.get('HTTP_APPNAME')

from service.account.account_base_service import AccountBaseService
Expand Down Expand Up @@ -79,7 +80,8 @@ def get(self, request, *args, **kwargs):
"""
workflow_id = kwargs.get('workflow_id')
request_data = request.GET
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')

app_name = request.META.get('HTTP_APPNAME')
from service.account.account_base_service import AccountBaseService
Expand Down Expand Up @@ -313,7 +315,8 @@ def get(self, request, *args, **kwargs):
"""
state_id = kwargs.get('state_id')
request_data = request.GET
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')
if not username:
return api_response(-1, '请提供username', '')

Expand All @@ -336,7 +339,8 @@ def get(self, request, *args, **kwargs):
"""
workflow_id = kwargs.get('workflow_id')
request_data = request.GET
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')
search_value = request_data.get('search_value', '')
per_page = int(request_data.get('per_page', 10)) if request_data.get('per_page', 10) else 10
page = int(request_data.get('page', 1)) if request_data.get('page', 1) else 1
Expand Down Expand Up @@ -457,7 +461,8 @@ def get(self, request, *args, **kwargs):
:return:
"""
request_data = request.GET
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')
if not username:
username = request.user.username
search_value = request_data.get('search_value', '')
Expand Down Expand Up @@ -563,7 +568,8 @@ def get(self, request, *args, **kwargs):
:return:
"""
request_data = request.GET
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')
if not username:
username = request.user.username
search_value = request_data.get('search_value', '')
Expand Down Expand Up @@ -672,7 +678,8 @@ def get(self, request, *args, **kwargs):
:return:
"""
request_data = request.GET
username = request_data.get('username', '') # 后续会根据username做必要的权限控制
# username = request_data.get('username', '') # 后续会根据username做必要的权限控制
username = request.META.get('HTTP_USERNAME')
if not username:
username = request.user.username
search_value = request_data.get('search_value', '')
Expand Down

0 comments on commit 513ca24

Please sign in to comment.