def edit_user_settings_page(request, org_id, store_id, this_employee_id): # Try to find the user. try: this_employee = Employee.objects.get(employee_id=this_employee_id) except Employee.DoesNotExist: this_employee = None organization = Organization.objects.get(org_id=org_id) return render( request, 'inventory_setting/employee/edit/view.html', { 'org': organization, 'store': Store.objects.get(store_id=store_id), 'stores': Store.objects.filter(organization=organization), 'employee': Employee.objects.get(user__id=request.user.id), 'this_employee': this_employee, 'form': EmployeeForm(instance=this_employee), 'user_form': UserForm() if this_employee is None else UserForm( instance=this_employee.user), 'tab': 'users_settings', 'locations': Store.objects.filter(organization_id=org_id), })
def ajax_register(request): """ Function provides user registration into our system. Any user that wants to log in using username / passwords is going to have to be registered by this function. """ response_data = {} if request.is_ajax(): if request.method == 'POST': form = UserForm(request.POST) # Validate the form: the captcha field will automatically # check the input if form.is_valid(): response_data = create_user(form) # Create our store else: response_data = { 'status': 'failed', 'message': json.dumps(form.errors) } else: response_data = { 'status': 'failure', 'message': 'Not acceptable request made.' } return HttpResponse(json.dumps(response_data), content_type="application/json")
def change_password_page(request): employee = Employee.objects.get_for_user_id_or_none(request.user.id) org = request.organization store = request.store # If user is logged in, fetch the Customer record or create one. Then # fetch a Receipt record or create a new one. customer = None receipt = None wishlists = None if request.user.is_authenticated(): customer = Customer.objects.get_or_create_for_user_email( request.user.email) receipt = Receipt.objects.get_or_create_for_online_customer(customer) wishlists = Wishlist.objects.filter_by_customer_id_or_none( customer.customer_id) # Display the view with all our model information. return render( request, 'store_customer/password/view.html', { 'customer_form': CustomerForm(instance=customer), 'user_form': UserForm(instance=customer), 'receipt': receipt, 'wishlists': wishlists, 'customer': customer, 'employee': employee, 'org': org, 'store': store, 'page': 'wishlist', })
def add_employee_page(request, org_id, store_id): organization = Organization.objects.get(org_id=org_id) return render( request, 'inventory_setting/employee/add/view.html', { 'org': organization, 'store': Store.objects.get(store_id=store_id), 'stores': Store.objects.filter(organization=organization), 'employee': Employee.objects.get(user__id=request.user.id), 'employee_form': EmployeeForm(initial={'joined': datetime.now()}), 'user_form': UserForm(), 'tab': 'users_settings', 'locations': Store.objects.filter(organization_id=org_id), })
def org_settings_page(request, org_id, store_id): employee = Employee.objects.get(user__id=request.user.id) form = OrganizationForm(instance=employee.organization) logo = employee.organization.logo return render(request, 'inventory_setting/org/view.html',{ 'org': employee.organization, 'store': Store.objects.get(store_id=store_id), 'upload_id': 0 if logo is None else logo.upload_id, 'tab':'org_settings', 'employee': employee, 'form': form, 'user_form': UserForm(instance=request.user), # Note: Possibly might error 'locations': Store.objects.filter(organization_id=org_id), })
def admin_settings_page(request, org_id, store_id): employee = Employee.objects.get(user__id=request.user.id) return render( request, 'inventory_setting/admin/view.html', { 'org': employee.organization, 'store': Store.objects.get(store_id=store_id), 'tab': 'admin_settings', 'employee': employee, 'user_form': UserForm( instance=request.user), # Note: Possibly might cause error 'locations': Store.objects.filter(organization_id=org_id), })