当前位置: 首页>>代码示例>>Python>>正文


Python utils.get_system_parameters函数代码示例

本文整理汇总了Python中shopcart.utils.get_system_parameters函数的典型用法代码示例。如果您正苦于以下问题:Python get_system_parameters函数的具体用法?Python get_system_parameters怎么用?Python get_system_parameters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_system_parameters函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

def register(request):
	ctx = {}
	ctx.update(csrf(request))
	ctx['system_para'] = get_system_parameters()
	ctx['menu_products'] = get_menu_products()
	ctx['page_name'] = 'Regitser'
	ctx = add_captcha(ctx) #添加验证码
	logger.debug('Enter register function.')
	if request.method == 'GET':
		#GET请求,直接返回页面
		return TemplateResponse(request,System_Config.get_template_name() + '/register.html',ctx)
	else:
		form = register_form(request.POST) # 获取Post表单数据
		if form.is_valid():# 验证表单
			from .utils import get_remote_ip
			ip = get_remote_ip(request)
			myuser = MyUser.objects.create_user(username=None,email=form.cleaned_data['email'].lower(),password=form.cleaned_data['password'],first_name=form.cleaned_data['first_name'],last_name=form.cleaned_data['last_name'])
			myuser.reg_ip = ip
			myuser.last_ip = ip
			myuser.save()
			
			#触发用户注册成功的事件
			signals.user_registration_success.send(sender='MyUser',user=myuser)
			#return redirect('/user/login')
			
			#准备登陆
			myuser.password = form.cleaned_data['password']
			return inner_login(request,myuser,ctx)
		else:
			logger.error('form is not valid')
			ctx['reg_result'] = _('Registration faild.')
			return TemplateResponse(request,System_Config.get_template_name() + '/register.html',ctx)			
开发者ID:icetusorg,项目名称:cetusshop,代码行数:32,代码来源:myuser.py

示例2: view_list

def view_list(request):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['page_name'] = 'Product'
	
	if request.method =='GET':
		product_list = None
		if 'sort_by' in request.GET:
			if 'direction' in request.GET:
				if 'desc' == request.GET['direction']:
					product_list = Product.objects.filter(is_publish=True).order_by(request.GET['sort_by']).reverse()
				else:
					product_list = Product.objects.filter(is_publish=True).order_by(request.GET['sort_by'])
				
				ctx['direction'] = request.GET['direction']
			else:
				product_list = Product.objects.filter(is_publish=True).order_by(request.GET['sort_by'])
		else:
			logger.debug("all products")
			product_list = Product.objects.filter(is_publish=True)
		
		logger.debug("no sort_by")
		if 'page_size' in request.GET:
			page_size = request.GET['page_size']
		else:
			try:
				page_size = int(System_Config.objects.get(name='product_page_size'))
			except:
				page_size = 12
		
		product_list, page_range = my_pagination(request=request, queryset=product_list,display_amount=page_size)
		
		ctx['product_list'] = product_list
		ctx['page_range'] = page_range
		return render(request,System_Config.get_template_name() + '/product_list.html',ctx)
开发者ID:imycart,项目名称:imycart,代码行数:35,代码来源:product.py

示例3: detail

def detail(request,id):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['page_name'] = 'Blog'
	try:
		article = Article.objects.get(id=id)
	except:
		raise Http404
		
	ctx['article'] = article
		
	if request.method =='GET': #正常访问,返回动态页面
		return render(request,System_Config.get_template_name() + '/article.html', ctx)
	elif request.method == 'POST':#通过ajax访问,生成静态文件
		content = render_to_string(System_Config.get_template_name() + '/article.html', ctx)
		result_dict = {}
		try:
			import codecs,os
			#先获取商品所属分类,作为目录
			dir = 'media/' + article.folder
			if not os.path.exists(dir):
				os.makedirs(dir)
			f = codecs.open(dir + article.static_file_name ,'w','utf-8')
			f.write(content)
			f.close()
			result_dict['success'] = True
			result_dict['message'] = _('File already generated.')
		except Exception as err:
			logger.error('写文件失败。' + str(err))
			result_dict['success'] = False
			result_dict['message'] = _('File generate failed.')
		finally:
			if f is not None:
				f.close()
		return JsonResponse(result_dict)
开发者ID:imycart,项目名称:imycart,代码行数:35,代码来源:article.py

示例4: email_add

def email_add(request):
    ctx = {}
    ctx.update(csrf(request))
    ctx['system_para'] = get_system_parameters()
    ctx['page_name'] = 'Inquiry'

    result_dict = {}
    if request.method == 'POST':
        form = email_inquiry_form(request.POST)  # 获取Post表单数据

        if form.is_valid():  # 验证表单
            inquiry = form.save()
            if inquiry.email == None or inquiry.email.strip() == '':
                result_dict['success'] = False
                result_dict['message'] = _('Email faild.')
                return JsonResponse(result_dict)

            from .utils import get_remote_ip
            ip = get_remote_ip(request)
            type = request.POST.get('type', '')
            inquiry.type = type
            inquiry.ip_address = ip
            inquiry.save()

            result_dict['success'] = True
            result_dict['message'] = _(
                'Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.')

            # 触发用户注册成功的事件
            signals.inquiry_received.send(sender='Inquiry', inquiry=inquiry)
        else:
            result_dict['success'] = False
            result_dict['message'] = _('Email Format Error.')
        return JsonResponse(result_dict)
开发者ID:icetusorg,项目名称:cetusshop,代码行数:34,代码来源:inquiry.py

示例5: price_adjusment

def price_adjusment(request):
	result_dict = {}
	if request.method == 'POST':
		order_id = request.POST.get('order_id','')
		price = request.POST.get('price_adjusment','0')
		
		logger.debug('price_adjusment:%s' % price)
		
		try:
			order = Order.objects.get(id=order_id)
			price = float(price)
		except Exception as err:
			logger.error('Can not find order [%s] \n Error Message:%s' %(order_id,err))
			result_dict['success'] = False
			result_dict['message'] = '价格调整失败'
			return JsonResponse(result_dict)
		
		
		order.price_adjusment = price
		order.calculate_total_price()
		order.save()
		result_dict['success'] = True
		result_dict['message'] = '价格调整成功'
		return JsonResponse(result_dict)
	else:
		ctx = {}
		ctx['system_para'] = get_system_parameters()
		ctx['page_name'] = '价格调整'
		ctx['order_id'] = request.GET.get('order_id')
		return TemplateResponse(request,System_Config.get_template_name('admin') + '/order_price_adjusment.html',ctx)
开发者ID:icetusorg,项目名称:cetusshop,代码行数:30,代码来源:order.py

示例6: user_active

def user_active(request,active):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['page_name'] = '用户管理'

	result_dict = {}
	result_dict['success'] = False
	result_dict['message'] = '用户状态保存失败'

	if request.method == 'POST':	
		user_id_list = request.POST.getlist('is_oper')
		status = False
		
		if active=='on':
			status = True
			
		try:
			for id in user_id_list:
				myuser = MyUser.objects.get(id=id)
				myuser.is_active = status
				myuser.save()
			result_dict['success'] = True
			result_dict['message'] = '用户状态保存成功'
		except Exception as err:
			logger.info('Can not find user which id=[%s]. \n Error Message : %s' % (id,err))
		return JsonResponse(result_dict)
	else:
		raise Http404
开发者ID:icetusorg,项目名称:cetusshop,代码行数:28,代码来源:user.py

示例7: info

def info(request):
	ctx = {}
	ctx.update(csrf(request))
	ctx['system_para'] = get_system_parameters()
	ctx['menu_products'] = get_menu_products()
	if request.method == 'GET':
		#GET请求,直接返回页面
		return render(request,System_Config.get_template_name() + '/user_info.html',ctx)
	else:
		logger.debug("Modify User Info")
		form = user_info_form(request.POST) # 获取Post表单数据
		myuser = request.user
		if form.is_valid():# 验证表单
			myuser.first_name = form.cleaned_data['first_name']
			myuser.last_name = form.cleaned_data['last_name']
			logger.debug(myuser.last_name)
		else:
			logger.debug('not validate')
		if 'changePassword' in request.POST:
			#需要更改密码
			myuser.set_password(request.POST['password'])
		else:
			#不更改密码
			logger.debug('not checked')
		myuser.save()
		return redirect('/user/info/?success=true')
开发者ID:imycartorg,项目名称:imycart,代码行数:26,代码来源:myuser.py

示例8: sort

def sort(request):
    ctx = {}
    ctx['system_para'] = get_system_parameters()
    ctx['page_name'] = '文章分类管理'

    if request.method == 'POST':
        result = {}
        result['success'] = False
        result['message'] = '文章分类排序失败'
        category = None

        try:
            id_list = request.POST.getlist('is_oper')
            for id in id_list:
                category = ArticleBusiCategory.objects.get(id=id)
                category.sort_order = request.POST.get('sort_order_%s' % id)
                category.save()
        except Exception as err:
            logger.info(
                'Can not find ArticleBusiCategory which id is [%s]. Create one. \n Error Message: %s' % (id, err))
            result['message'] = '对编号为[%s]的文章分类重排序时出错' % id
            return JsonResponse(result)

        result['success'] = True
        result['message'] = '文章分类排序成功'
        result['category_id'] = category.id
        return JsonResponse(result)

    else:
        raise Http404
开发者ID:icetusorg,项目名称:cetusshop,代码行数:30,代码来源:article_busi_category.py

示例9: list_view

def list_view(request):
    ctx = {}
    ctx['system_para'] = get_system_parameters()
    ctx['page_name'] = '招聘管理'

    if request.method == 'GET':

        all = Recruit.objects.all().order_by('-sort_order')

        page_size = get_page_size()

        count = len(all)
        recruit_list, page_range, current_page = my_pagination(request=request, queryset=all, display_amount=page_size)
        logger.debug('current_page:%s' % current_page)

        # 为页面准备分类的下拉列表
        # from shopcart.myadmin.article_busi_category import get_all_category
        # busi_category_list = get_all_category()
        # logger.debug('busi_category_list : %s' % busi_category_list)
        # ctx['busi_category_list'] = busi_category_list

        ctx['recruit_list'] = recruit_list
        ctx['page_range'] = page_range
        ctx['page_size'] = page_size
        ctx['current_page'] = current_page
        ctx['recruit_count'] = count
        return TemplateResponse(request, System_Config.get_template_name('admin') + '/recruit_list.html', ctx)
    else:
        raise Http404
开发者ID:icetusorg,项目名称:cetusshop,代码行数:29,代码来源:recruit.py

示例10: user_reset_password

def user_reset_password(request):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['page_name'] = '用户管理'

	result_dict = {}
	result_dict['success'] = False
	result_dict['message'] = '用户密码重置失败'

	if request.method == 'POST':	
		user_id_list = request.POST.getlist('is_oper')		
		import uuid,datetime
		try:
			for id in user_id_list:
				myuser = MyUser.objects.get(id=id)
				s_uuid = str(uuid.uuid4())
				reset_password = Reset_Password.objects.create(email=myuser.email,validate_code=s_uuid,apply_time=datetime.datetime.now(),expirt_time=(datetime.datetime.now() + datetime.timedelta(hours=24)),is_active=True)
			
				#触发用户申请重置密码的事件	
				signals.user_password_modify_applied.send(sender='MyUser',reset_password=reset_password)
			
			result_dict['success'] = True
			result_dict['message'] = '用户密码重置请求已发出,请用户在24小时内点击邮件内链接重新设置密码。'
		except Exception as err:
			logger.info('Can not find user which id=[%s]. \n Error Message : %s' % (id,err))
		return JsonResponse(result_dict)
	else:
		raise Http404		
开发者ID:icetusorg,项目名称:cetusshop,代码行数:28,代码来源:user.py

示例11: reset_password

def reset_password(request):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['page_name'] = 'Reset Password'
	if request.method == 'GET':
		ctx['success_display'] = 'display:none;'
		ctx['form_display'] = ''
		try:
			#日期大小与比较要用 "日期字段名__gt=" 表示大于
			reset_password = Reset_Password.objects.filter(expirt_time__gt=datetime.datetime.now()).get(email=request.GET['email'],validate_code=request.GET['validate_code'],is_active=True)
			ctx['email'] = reset_password.email
			ctx['validate_code'] = reset_password.validate_code
			return render(request,System_Config.get_template_name() + '/reset_password.html',ctx)
		except:
			raise Http404
			#ctx['form_display'] = 'none'
			#ctx['reset_message'] = _('Can not find the password reset apply request.')
	else:
		try:
			reset_password = Reset_Password.objects.filter(expirt_time__gt=datetime.datetime.now()).get(email=request.POST['email'],validate_code=request.POST['validate_code'],is_active=True)
			myuser = MyUser.objects.get(email=reset_password.email)
			myuser.set_password(request.POST['password'])
			reset_password.is_active = False
			reset_password.save()
			myuser.save()
			ctx['success_display'] = ''
			ctx['form_display'] = 'display:none;'
			ctx['reset_message'] = _('The password has been reseted.')
		except:
			ctx['success_display'] = ''
			ctx['form_display'] = 'display:none;'
			ctx['reset_message'] = _('Opration faild.')		
		return render(request,System_Config.get_template_name() + '/reset_password.html',ctx)
开发者ID:imycart,项目名称:imycart,代码行数:33,代码来源:myuser.py

示例12: view_cart

def view_cart(request):
    if 'cart_id' in request.COOKIES:
        cart_id = request.COOKIES["cart_id"]
        cart, created = Cart.objects.get_or_create(id=cart_id)
    else:
        if request.user.is_authenticated():
            cart, object = Cart.objects.get_or_create(user=request.user)
        else:
            cart = Cart.objects.create(user=None)

    if request.is_ajax():
        ret_dict = {}
        ret_dict['success'] = True
        ret_dict['item_type_count'] = cart.cart_products.all().count()

        from shopcart.serializer import serializer
        # serialized_cart = serializer(cart,datetime_format='string',output_type='dict',many=True)

        # 先不返回购物车中商品信息
        serialized_cart = serializer(cart, datetime_format='string', output_type='dict', many=False)
        # logger.debug(serialized_cart)
        ret_dict['cart'] = serialized_cart
        return JsonResponse(ret_dict)

    else:
        ctx = {}
        ctx['system_para'] = get_system_parameters()
        ctx['menu_products'] = get_menu_products()
        ctx['page_name'] = 'My Cart'
        if request.method == 'GET':
            ctx['cart'] = cart
            response = TemplateResponse(request, System_Config.get_template_name() + '/cart_detail.html', ctx)
            response.set_cookie('cart_id', cart.id, max_age=3600 * 24 * 365)
            return response
开发者ID:icetusorg,项目名称:cetusshop,代码行数:34,代码来源:cart.py

示例13: list_view

def list_view(request):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['page_name'] = '订单管理'
	
	if request.method == 'GET':
		order_number = request.GET.get('order_number','')
		ctx['order_number'] = order_number
		user_email = request.GET.get('user_email','')
		ctx['user_email'] = user_email
		
		all = Order.objects.all()
		
		if order_number != '':
			all = all.filter(order_number=order_number)
		
		if user_email != '':
			all = all.filter(user__email=user_email)
		
		
		page_size = get_page_size()
		order_list, page_range = my_pagination(request=request, queryset=all,display_amount=page_size)
		
		ctx['order_list'] = order_list
		ctx['page_range'] = page_range
		ctx['page_size'] = page_size
		ctx['order_count'] = all.count()
		return render(request,get_admin_template_name('order_list_content.html'),ctx)
	else:
		raise Http404
开发者ID:imycartorg,项目名称:imycart,代码行数:30,代码来源:order.py

示例14: payment

def payment(request,order_id):
	ctx = {}
	ctx['system_para'] = get_system_parameters()
	ctx['menu_products'] = get_menu_products()
	ctx['page_name'] = 'Payment'
	
	order = Order.objects.get(id=order_id)
	
	ctx['paypal_account'] = System_Config.objects.get(name='paypal_account').val
	ctx['item_name'] = 'Your order:' + str(order.order_number) + " in " + System_Config.objects.get(name='site_name').val
	ctx['custom'] = order.order_number #向paypal传送本地订单编号
	ctx['amount'] = order.order_amount
	ctx['return_url'] =  System_Config.objects.get(name='base_url').val + "/order/show/"
	ctx['cancel_url'] = System_Config.objects.get(name='base_url').val + "/order/show/"
	ctx['notify_url'] = System_Config.objects.get(name='base_url').val + reverse('paypal-ipn')
	ctx['cmd'] = '_xclick'
	ctx['currency_code'] = System_Config.objects.get(name='default_currency').val
	ctx['charset'] = 'utf-8'
	ctx['rm'] = '1'
	
	
	paypal_env = 'sandbox'
	try:
		paypal_env = System_Config.objects.get(name='paypal_env').val
	except:
		logger.info('"paypal_env" is not definded,use default value : "sandbox".Please set the system parameter paypal_env = live if you want to use the paypal live service.')
	if paypal_env == 'live':
		ctx['paypal_action_url'] = 'https://www.paypal.com/cgi-bin/websc'
	else:
		ctx['paypal_action_url'] = 'https://www.sandbox.paypal.com/cgi-bin/websc'
	
	return render(request,System_Config.get_template_name() + '/payment.html',ctx)		
开发者ID:imycartorg,项目名称:imycart,代码行数:32,代码来源:order.py

示例15: detail

def detail(request, id=None):
    ctx = {}
    ctx['system_para'] = get_system_parameters()
    ctx['page_name'] = '自定义URL管理'
    try:
        customize_url = CustomizeURL.objects.get(id=id)
    except Exception as err:
        logger.error("Can not find customize_url which id is %s" % id)
        raise Http404

    if request.method == 'GET':
        ctx['customize_url'] = customize_url
        return TemplateResponse(request, System_Config.get_template_name('admin') + '/cust_url_detail.html', ctx)
    else:
        result = {}
        result['success'] = False
        result['message'] = '自定义URL保存失败'

        from shopcart.forms import customize_url_detail_form
        form = customize_url_detail_form(request.POST, instance=customize_url)

        if form.is_valid():
            customize_url = form.save()
            result['success'] = True
            result['message'] = '自定义URL保存成功'

        return JsonResponse(result)
开发者ID:icetusorg,项目名称:cetusshop,代码行数:27,代码来源:customize_url.py


注:本文中的shopcart.utils.get_system_parameters函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。