Skip to content

Commit

Permalink
Merge pull request #1204 from hanshuaikang/feature/develop_by_han
Browse files Browse the repository at this point in the history
bugfix: 修复移动端登陆跳转的问题
  • Loading branch information
hanshuaikang authored Sep 25, 2023
2 parents 27fe8e7 + c6bcd9d commit 579a369
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,3 +910,6 @@ def redirect_func(request):
)

FOOTER = os.getenv("BKAPP_FOOTER", None)

ENABLE_NOTIFY_ROUTER = os.getenv("BKAPP_ENABLE_NOTIFY_ROUTER", False)
NOTIFY_ROUTER_NAME = os.getenv("BKAPP_NOTIFY_ROUTER_NAME", "router")
19 changes: 14 additions & 5 deletions error_pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,42 @@
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from django.conf import settings
from django.http import HttpResponseRedirect

from common.mymako import render_mako_context


def error_404(request):
def error_404(request, exception):
"""
404提示页
"""
return render_mako_context(request, '404.html')
if settings.ENABLE_NOTIFY_ROUTER:
url_flag = "/{}/".format(settings.NOTIFY_ROUTER_NAME)
if url_flag in request.path:
return HttpResponseRedirect(
request.get_full_path().replace(url_flag, "/#/")
)

return render_mako_context(request, "404.html")


def error_500(request):
"""
500提示页
"""
return render_mako_context(request, '500.html')
return render_mako_context(request, "500.html")


def error_401(request):
"""
401提示页
"""
return render_mako_context(request, '401.html')
return render_mako_context(request, "401.html")


def error_403(request, exception):
"""
403提示页
"""
return render_mako_context(request, '403.html')
return render_mako_context(request, "403.html")
7 changes: 6 additions & 1 deletion itsm/ticket/models/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1552,8 +1552,13 @@ def generate_ticket_url(self, state_id, receivers):
"state_id": state_id,
}
)
self.notify_url = "{site_url}/#/ticket/{ticket_id}/?token={token}&step_id={step_id}".format(
flag = "#"
if settings.ENABLE_NOTIFY_ROUTER:
flag = settings.NOTIFY_ROUTER_NAME

self.notify_url = "{site_url}/{flag}/ticket/{ticket_id}/?token={token}&step_id={step_id}".format(
# noqa
flag=flag,
site_url=settings.TICKET_NOTIFY_HOST.rstrip("/"),
ticket_id=self.id,
token=ticket_token,
Expand Down
2 changes: 1 addition & 1 deletion urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
url(r"^", include("itsm.sites.urls")),
]

# handler404 = 'error_pages.views.error_404'
handler404 = "error_pages.views.error_404"
handler500 = "error_pages.views.error_500"
handler403 = "error_pages.views.error_403"
handler401 = "error_pages.views.error_401"
Expand Down

0 comments on commit 579a369

Please sign in to comment.