Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.views.decorators.csrf import csrf_exempt
- from sendfast.models import *
- from sendfast.common import constants, utils, pStrings, cachekeys, commonRestaurantFunctions
- from django.core.cache import cache
- import binascii
- import logging
- logger = logging.getLogger(__name__) #not sure what this does
- @csrf_exempt
- def signup(request):
- if request.method == pStrings.POST_METHOD:
- restaurant_name = request.POST.get(pStrings.RESTAURANT_NAME, None) #DECLARE NEW PSTRING RESTAURANT_NAME
- restaurant_owner_name = request.POST.get(pStrings.RESTAURANT_OWNER_NAME, None) #DECLARE NEW PSTRING RESTAURANT_OWNER__NAME
- restaurant_address = request.POST.get(pStrings.RESTAURANT_ADDRESS, None) #DECLARE NEW PSTRING RESTAURANT_ADDRESS
- #resturant_hub_id = request.POST.get(pStrings.RESTAURANT_HUB_ID, None) #DECLARE NEW PSTRING RESTAURANT_HUB_ID
- #It would be a good idea if latitude , longitude are set null and blank = True
- #set all other as null =True in model
- restaurant_email_id = request.POST.get(pStrings.RESTAURANT_EMAIL_ID, None)#DECLARE
- restaurant_phone_no = request.POST.get(pStrings.RESTAURANT_PHONE_NO, None)#DECLARE
- restaurant_username = request.POST.get(pStrings.RESTAURANT_USERNAME, None)#DECLARE
- password = request.POST.get(pStrings.PASSWORD, None)
- if restaurant_name is not None and restaurant_owner_name is not None and restaurant_address is not None \
- and restaurant_email_id is not None and restaurant_phone_no is not None :
- created = create_new_restaurant(restaurant_name=restaurant_name,restaurant_owner_name=restaurant_owner_name,
- restaurant_address=restaurant_address,restaurant_email_id=restaurant_email_id
- restaurant_phone_no=restaurant_phone_no)
- if created:
- new_restaurant = Restaurant_static_data.get(restaurant_name=restaurant_name,restaurant_owner_name=restaurant_owner_name)
- new_restaurant_id = new_restaurant.restaurant_id
- create_login_details(restaurant_id = new_restaurant_id, restaurant_username=restaurant_username, password = password)
- if mobile_number_verified:
- return set_mobile_verified(new_restaurant_id)
- else:
- pass
- #depends on the code of mobile_number_verified
- if email_id_verified:
- return set_email_id_verified(new_restaurant_id)
- else:
- pass
- if mobile_number_verified and email_id_verified:
- restaurant = Restaurant_static_data.objects.get(restaurant_id=new_restaurant_id)
- restaurant.restaurant_is_Active = True
- # Return appropiate response
- else:
- return utils.json_error_response(constants.INVALID_SIGNUP_DETAILS,
- constants.ERROR_STATUS_400) #DECLARE CONSTANT INVALID_SIGNUP_DEATIALS
- else:
- return utils.json_error_response(constants.INVALID_DATA, constants.ERROR_STATUS_400)
- else:
- return utils.json_error_response(constants.INVALID_METHOD, constants.ERROR_STATUS_405)
- def create_new_restaurant(restaurant_name,restaurant_owner_name,restaurant_email_id,
- restaurant_address,restaurant_phone_no, restaurant_hub_id):
- try:
- Restaurant_static_data.objects.create(restaurant_name=restaurant_name,restaurant_owner_name=restaurant_owner_name,
- restaurant_address=restaurant_address,restaurant_email_id=restaurant_email_id
- restaurant_phone_no=restaurant_phone_no,restaurant_hub_id=restaurant_hub_id)
- return True
- except:
- return False
- def create_login_details(restaurant_id, restaurant_username, password):
- try:
- Restaurant_login_details.objects.get_or_create(restaurant_id = restaurant_id,
- restaurant_username=restaurant_name,
- password = password,is_restaurant_logged_in = True)
- def mobile_number_verified():
- pass
- #code for gupshup service goes here
- def set_mobile_verified(new_restaurant_id):
- try:
- restaurant = Restaurant_static_data.objects.get(restaurant_id=new_restaurant_id)
- restaurant.mobile_verified = True
- #create restaurant _mobile_verifed in static data
- def email_id_verified():
- pass
- #Authentiacte using OAuth or whatever
- def set_email_verified(new_restaurant_id):
- try:
- restaurant = Restaurant_static_data.objects.get(restaurant_id=new_restaurant_id)
- restaurant.email_verified = True
- #create restaurant _email_verifed in static data
Add Comment
Please, Sign In to add comment