def manage_user(request): # Manage Accounts entry page if settings.DEBUG: print(settings.APPLICATION_TITLE, "in accounts.views.manage_user via manage_account") # get_user_record uses request.user to lookup AUTH_USER_MODEL/get_user_model() # to retrieve the user record user = get_user_record(request.user) if settings.DEBUG: print("is this a Developer?", user.is_developer, "[", request.user.is_developer, "]") print("is this a Beneficiary?", user.is_user, "[", request.user.is_user, "]") mfa_address = cell_email(user.mobile, user.carrier) context = { "user": user, "mfa_address": mfa_address, } return render_to_response('accounts/manage_user.html', RequestContext( request, context, ))
def manage_account(request): # Manage Accounts entry page # DONE: Remove api.data.gov signup widget in manage_account.html application_title = settings.APPLICATION_TITLE DEBUG = settings.DEBUG_SETTINGS if DEBUG: print(application_title, "in accounts.views.manage_account") user = request.user mfa_address = cell_email(user.mobile, user.carrier) # Get a list of organizations for this user # org_list = list(Organization.objects.all()) org_list = list(Organization.objects.filter(owner=user)) app_list = list(OrgApplication.objects.filter(user=user)) context = {"title": "Manage Account", "user": user, "mfa_address": mfa_address, "organizations": org_list, "applications": app_list} return render_to_response('accounts/manage_account.html', RequestContext(request, context,))
def manage_account(request): # Manage Accounts entry page # DONE: Remove api.data.gov signup widget in manage_account.html application_title = settings.APPLICATION_TITLE DEBUG = settings.DEBUG_SETTINGS if DEBUG: print(application_title, "in accounts.views.manage_account") user = request.user mfa_address = cell_email(user.mobile, user.carrier) # Get a list of organizations for this user # org_list = list(Organization.objects.all()) org_list = list(Organization.objects.filter(owner=user)) app_list = list(OrgApplication.objects.filter(user=user)) context = { "title": "Manage Account", "user": user, "mfa_address": mfa_address, "organizations": org_list, "applications": app_list } return render_to_response('accounts/manage_account.html', RequestContext( request, context, ))
def save(self, **kwargs): up = self.user rand_code = random.randint(1000, 9999) if not self.sms_code: if up.mobile != '+19999999999': self.sms_code = rand_code else: self.sms_code = '9999' if settings.DEBUG: print(self.sms_code) now = timezone.now() expires = now + timedelta(minutes=settings.SMS_LOGIN_TIMEOUT_MIN) self.expires = expires # Removing mfa check. # Only call ValidSMSCode is user.MFA is true or Verifying phone phone_email = cell_email(up.mobile, up.carrier) # send an sms code self.send_outcome = send_sms_pin(phone_email, self.sms_code) super(ValidSMSCode, self).save(**kwargs)
def save(self, **kwargs): up = self.user rand_code = random.randint(1000, 9999) if not self.sms_code: if up.mobile != '+19999999999': self.sms_code = rand_code else: self.sms_code = '9999' if settings.DEBUG: print(self.sms_code) now = timezone.now() expires = now + timedelta(minutes=settings.SMS_LOGIN_TIMEOUT_MIN) self.expires = expires if up.mfa: new_number = cell_email(up.mobile, up.carrier) #send an sms code self.send_outcome = send_sms_pin(up.mobile, new_number, self.sms_code) else: self.send_outcome = '' super(ValidSMSCode, self).save(**kwargs)
def manage_account(request): # Manage Accounts entry page if settings.DEBUG: print(settings.APPLICATION_TITLE, "in accounts.views.manage_account") user = request.user mfa_address = cell_email(user.mobile, user.carrier) try: org = Organization.objects.filter(owner=user) except Organization.DoesNotExist: org = {} if settings.DEBUG: print("Organization", org) context = {"user": user, "org": org, "mfa_address": mfa_address, } return render_to_response('accounts/manage_account.html', RequestContext(request, context, ))
def save(self, **kwargs): up=self.user rand_code=random.randint(1000,9999) if not self.sms_code: if up.mobile != '+19999999999': self.sms_code = rand_code else: self.sms_code = '9999' if settings.DEBUG: print(self.sms_code) now = timezone.now() expires = now + timedelta(minutes=settings.SMS_LOGIN_TIMEOUT_MIN) self.expires = expires if up.mfa: new_number = cell_email(up.mobile, up.carrier) #send an sms code self.send_outcome = send_sms_pin(up.mobile, new_number, self.sms_code ) else: self.send_outcome = '' super(ValidSMSCode, self).save(**kwargs)
def manage_user(request): # Manage Accounts entry page if settings.DEBUG: print(settings.APPLICATION_TITLE, "in accounts.views.manage_user via manage_account") # get_user_record uses request.user to lookup AUTH_USER_MODEL/get_user_model() # to retrieve the user record user = get_user_record(request.user) if settings.DEBUG: print("is this a Developer?", user.is_developer, "[", request.user.is_developer ,"]") print("is this a Beneficiary?", user.is_user, "[", request.user.is_user ,"]") mfa_address = cell_email(user.mobile, user.carrier) context = {"user": user, "mfa_address": mfa_address, } return render_to_response('accounts/manage_user.html', RequestContext(request, context, ))
def manage_account(request): # Manage Accounts entry page if settings.DEBUG: print(settings.APPLICATION_TITLE, "in accounts.views.manage_account") account_model = get_user_model() access_field = settings.USERNAME_FIELD user = account_model.objects.get(**{access_field:request.user}) mfa_address = cell_email(user.mobile, user.carrier) try: org = Organization.objects.get(name=request.user.organization) except Organization.DoesNotExist: org = {} # get my Developer role try: my_dev = Developer.objects.get(member=user) my_role = my_dev.role if my_dev.role in ['1','2']: org_owner = True else: org_owner = False except Developer.DoesNotExist: my_dev = {} my_role = "" org_owner = False # get the dev team members try: my_team = Developer.objects.filter(organization=user.organization).order_by('role') except Developer.DoesNotExist: my_team = {} # get the email_domain for user domain = "@" + user.get_email_domain() # get users with the same domain in email address as candidates to add try: candidates = account_model.objects.filter(email__icontains=domain, organization=None) except account_model.DoesNotExist: candidates = {} if settings.DEBUG: print("User:"******"Organization:", org, "[", org.name, "]") print("My_Dev_Role :", my_dev, "[", my_role, "]") print("My_Dev_Team :", my_team) print("Candidates :", candidates) context = {"user": user, "my_role": my_role, "org_owner": org_owner, "mfa_address": mfa_address, "domain": domain, "org": org, "my_dev": my_dev, "my_team": my_team, "candidates": candidates, } # return render_to_response('accounts/manage_account.html', # RequestContext(request, context, )) # Using Alternate manage_account template return render_to_response('appmgmt/manage_account.html', RequestContext(request, context, ))
def manage_developer(request): # Manage Developer Account entry page if settings.DEBUG: print(settings.APPLICATION_TITLE, "in accounts.views.manage_developer via manage_account") account_model = get_user_model() access_field = settings.USERNAME_FIELD user = get_user_record(request.user) mfa_address = cell_email(user.mobile, user.carrier) try: org = Organization.objects.get(name=request.user.organization) except Organization.DoesNotExist: org = {} # org.update({'name': ""}) # get my Developer role try: my_dev = Developer.objects.get(member=user) my_role = my_dev.role if my_dev.role in ['1', '2']: org_owner = True else: org_owner = False except Developer.DoesNotExist: my_dev = {} my_role = "" org_owner = False # get the dev team members try: my_team = Developer.objects.filter( organization=user.organization).order_by('role') except Developer.DoesNotExist: my_team = {} # get the email_domain for user domain = "@" + user.get_email_domain() # get users with the same domain in email address as candidates to add try: candidates = account_model.objects.filter(email__icontains=domain, organization=None) except account_model.DoesNotExist: candidates = {} if settings.DEBUG: print("User:"******"Organization:", org) print("My_Dev_Role :", my_dev, "[", my_role, "]") print("My_Dev_Team :", my_team) print("Candidates :", candidates) context = { "user": user, "my_role": my_role, "org_owner": org_owner, "mfa_address": mfa_address, "domain": domain, "org": org, "my_dev": my_dev, "my_team": my_team, "candidates": candidates, } # return render_to_response('accounts/manage_account.html', # RequestContext(request, context, )) # Using Alternate manage_account template return render_to_response('appmgmt/manage_developer.html', RequestContext( request, context, ))
def manage_account(request): # Manage Accounts entry page # DONE: Remove api.data.gov signup widget in manage_account.html if settings.DEBUG: print(settings.APPLICATION_TITLE, "in accounts.views.manage_account") user = request.user mfa_address = cell_email(user.mobile, user.carrier) dev_list = list(Device.objects.filter(user_id=request.user, deleted=False)) # DONE: Get Device Used indicator # Used Field is included in Device. It is set during login try: xwalk = Crosswalk.objects.get(user=request.user) mmg_xwalk = {} mmg_xwalk['mmg_user'] = xwalk.mmg_user mmg_xwalk['mmg_name'] = xwalk.mmg_name mmg_xwalk['mmg_email'] = xwalk.mmg_email mmg_xwalk['mmg_account'] = xwalk.mmg_account mmg_xwalk['mmg_bbdata'] = xwalk.mmg_bbdata mmg_xwalk['mmg_bbfhir'] = xwalk.mmg_bbfhir temp = xwalk.mmg_bbjson # if settings.DEBUG: # print("Temp:", temp) #temp2 = json.loads(eval(temp)) #temp = json.loads(json.dumps(xwalk.mmg_bbjson),object_pairs_hook=OrderedDict) #temp = json.dumps(serializers.serialize(xwalk.mmg_bbjson)) #print("Temp2:", temp2) #print("========") #for key, value in temp2.items(): # print("Key:", key, ":", temp[key]) mmg_xwalk['mmg_bbjson'] = temp # print("patient:", temp['patient']) except Crosswalk.DoesNotExist: mmg_xwalk = {} try: secretqa = QA.objects.get(user=request.user) except QA.DoesNotExist: secretqa = None if settings.DEBUG: print("secretqa-QA",secretqa) if secretqa == None: security_mode = "add" else: security_mode = "edit" security_list = secretqa context = {"user": user, "mfa_address": mfa_address, "mmg_xwalk": mmg_xwalk, "devices": dev_list, 'security_mode': security_mode, "security": security_list} return render_to_response('accounts/manage_account.html', RequestContext(request, context, ))