def register(request, menu): groups = utils.stringify_groups(request.user) use_cdms = True if len(set([Roles.ASCS, Roles.DEALERS, Roles.SDMANAGERS]).intersection(set(groups))) == 0: return HttpResponseBadRequest() if request.method == 'GET': user_id = request.user reset_password = models.UserProfile.objects.get(user=request.user).reset_password if not reset_password: return render(request, 'portal/change_password.html') if Roles.DEALERS in groups: use_cdms=models.Dealer.objects.get(user__user=user_id).use_cdms return render(request, TEMPLATE_MAPPING.get(menu, 'portal/404.html'), {'active_menu' : ACTIVE_MENU.get(menu)\ , 'groups': groups, 'user_id' : user_id, 'use_cdms' : use_cdms}) elif request.method == 'POST': save_user = { 'asc': save_asc_registration, 'sa': save_sa_registration, 'customer': register_customer } try: response_object = save_user[menu](request, groups) return HttpResponse(response_object, content_type="application/json") except Exception as ex: logger.error('[registration failure {0}] : {1}'.format(menu, ex)) return HttpResponseBadRequest() else: return HttpResponseBadRequest()
def register(request, menu): groups = utils.stringify_groups(request.user) if not (Roles.ASCS in groups or Roles.DEALERS in groups): return HttpResponseBadRequest() if request.method == 'GET': user_id = request.user return render(request, TEMPLATE_MAPPING.get(menu), {'active_menu' : ACTIVE_MENU.get(menu)\ , 'groups': groups, 'user_id' : user_id}) elif request.method == 'POST': save_user = { 'asc': save_asc_registration, 'sa': save_sa_registration, 'customer': register_customer } try: response_object = save_user[menu](request, groups) return HttpResponse(response_object, content_type="application/json") except Exception as ex: logger.error('[registration failure {0}] : {1}'.format(menu, ex)) return HttpResponseBadRequest() else: return HttpResponseBadRequest()