本文整理汇总了Python中apps.dajax.core.Dajax.json方法的典型用法代码示例。如果您正苦于以下问题:Python Dajax.json方法的具体用法?Python Dajax.json怎么用?Python Dajax.json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.dajax.core.Dajax
的用法示例。
在下文中一共展示了Dajax.json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_discount
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def add_discount(request,product,names,rates,eff_dates,exp_dates):
dajax = Dajax()
print "inside add discount"
print product,names,rates,eff_dates,exp_dates
product = get_object_or_404(Product, id=int(product))
print product
if len(names) == len(rates) == len(eff_dates) == len(exp_dates):
for x in range(0, len(names)):
print x,names[x]
discount = Discount()
discount.product = product
discount.name = names[x]
discount.discount = rates[x]
discount.effe_date = datetime.datetime.strptime(eff_dates[x], '%d/%m/%Y')
discount.expi_date = datetime.datetime.strptime(exp_dates[x], '%d/%m/%Y')
discount.save()
dajax.script('DiscountShow();')
else:
print "Not a valid form"
dajax.script('DiscountError();')
return dajax.json()
示例2: delete_message
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def delete_message(request, iid, type):
dajax = Dajax()
response_data = {}
if iid:
if type == "inbox_list":
update_emails(request, iid)
response_data['type'] = "inbox_list"
response_data['id'] = json.dumps(iid)
return json.dumps(response_data)
elif type == "sent_list":
update_sent_emails(request, iid)
response_data['type'] = "inbox_list"
response_data['id'] = json.dumps(iid)
return json.dumps(response_data)
elif type == "inbox_detail":
update_emails(request, iid)
response_data['type'] = "inbox_detail"
return json.dumps(response_data)
elif type == "sent_detail":
response_data['type'] = "sent_detail"
email = Emails.objects.get(pk=int(iid))
if not email.from_delete:
email.from_delete = True
email.save()
return json.dumps(response_data)
return dajax.json()
示例3: signup
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def signup(request, email=None, pwd=None, cpwd=None):
dajax = Dajax()
print "inside signup"
if email and pwd:
if pwd == cpwd:
if User.objects.filter(email=email) or User.objects.filter(username=email):
return simplejson.dumps(
{
"status": "warning",
"message": "A User already exist with this email address.Please select a different email address or login",
}
)
else:
print "################################"
staff = Staff()
staff.username = email
staff.email = email
staff.set_password(pwd)
staff.save()
user = authenticate(username=staff.username, password=pwd)
if user:
login(request, user)
return simplejson.dumps({"status": "reload", "message": "move to dashboard."})
else:
return simplejson.dumps({"status": "warning", "message": "Password Mismacthing"})
else:
print "Enter Valid Form"
return simplejson.dumps({"status": "warning", "message": "Enter Valid Form."})
return dajax.json()
示例4: savephone
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def savephone(request, phone_no=None, cid=None):
dajax = Dajax()
dajax.assign("#message", "innerHTML", "")
if request.user.is_authenticated:
if phone_no:
customer = Customer.objects.get(id=cid)
print customer
phone = PhoneNumber()
phone.customer = customer
phone.phone_no = phone_no
phone.save()
dajax.assign(
"#message",
"innerHTML",
""" <div class="alert alert-success"> Successfully added phone number to customer {0} <div>""".format(
customer.name
),
)
dajax.script("LocationReload();")
else:
dajax.assign(
"#message",
"innerHTML",
""" <div class="alert alert-danger"> Please Enter valid information </div></div>""",
)
return dajax.json()
示例5: remove_phone
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def remove_phone(request, customer_id=None, phone_id=None):
dajax = Dajax()
dajax.assign("#message1", "innerHTML", "")
if request.user.is_authenticated:
if customer_id:
customer = Customer.objects.get(id=customer_id)
if customer:
phone = PhoneNumber.objects.get(id=phone_id)
phone.delete()
dajax.assign(
"#message1",
"innerHTML",
""" <div class="alert alert-success"> Successfully Removed customer {0} PhoneNumber<div>""".format(
customer.name
),
)
dajax.script("LocationReload();")
else:
dajax.assign(
"#message1", "innerHTML", """<div class="alert alert-danger"> No permission </div></div>"""
)
else:
dajax.assign("#message1", "innerHTML", """ <div class="alert alert-danger"> No permission </div></div>""")
return dajax.json()
示例6: edit_sales_tax
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def edit_sales_tax(request,tid,state,tax):
dajax = Dajax()
print "Edit Sale Taxes"
if isinstance(request.user,Staff) and request.user.user_type == 'A':
if tid and state and float(tax):
sale_tax = SaleTax.objects.get(id=tid)
print sale_tax,tid,state,float(tax)
sale_tax.state = state
sale_tax.tax_amount = float(tax)
sale_tax.save()
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The state <b> {0} </b> has been updated successfully .'.format(sale_tax.state))
dajax.script("Success();")
else:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', "We're sorry, but something went wrong. Please be sure that you entered a valid form.")
dajax.script("Warning();")
return dajax.json()
示例7: edit_slider_content
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def edit_slider_content(request,lang,sid=None,title=None,caption=None,url=None,priority=None):
dajax = Dajax()
if isinstance(request.user,Staff) and request.user.user_type == 'A':
try:
slider = Slider.objects.get(id=sid)
if title and caption and priority:
if lang == 'zh':
slider.title_zh = title
slider.captions_zh = caption
else:
slider.title = title
slider.captions = caption
slider.url = url
slider.priority = priority
slider.save()
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The <b> {0} </b> has been edited successfully .'.format(slider.title))
dajax.script("HIDEmodal();")
# dajax.script("Success();")
else:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', 'Something went wrong')
# dajax.script("Warning();")
dajax.script("HIDEWmodal();")
except Slider.DoesNotExist:
pass
else:
return HttpResponseRedirect(reverse('login'))
return dajax.json()
示例8: delete_repo
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def delete_repo(request,rid):
dajax = Dajax()
if isinstance(request.user,Staff) and request.user.user_type == 'P':
if rid:
Product.objects.get(id=int(rid)).delete()
dajax.script('LocationReload();')
elif isinstance(request.user,Staff) and request.user.user_type == 'E':
if rid:
product = Product.objects.get(id=int(rid))
product.is_delete = True
product.save()
dajax.script('SuccessReturn();')
elif isinstance(request.user,Staff) and request.user.user_type == 'A':
if rid:
product = Product.objects.get(id=int(rid))
product.delete()
dajax.script('SuccessReturn();')
return dajax.json()
示例9: get_shipping_rate
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def get_shipping_rate(request,weight,unit):
dajax = Dajax()
print "inside the Sales tax"
dajax.assign('#shipping_rate', 'value', '')
if weight and unit:
if unit == 'GM':
weight = float(weight)/1000
price = 0.0
try:
sr = ShippingCharges.objects.filter(min_weight__lte=float(weight),max_weight__gte=float(weight)).order_by('-id')[0]
price = sr.amount
except:
sr = ShippingCharges.objects.filter(min_weight__lte=float(weight),is_infinite=True).order_by('-id')[0]
price = sr.amount
shipping_rate = float(weight)*float(price)
default_rate = float(SiteConfigurations.objects.get().shipping_charge_default)
print "Default####",default_rate
if shipping_rate < default_rate:
shipping_rate = default_rate
print "Shipping ######",shipping_rate
dajax.assign('#shipping_rate', 'value','{0}'.format(format(shipping_rate,'.2f')))
dajax.script('Calculation();')
return dajax.json()
示例10: delete_product
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def delete_product(request,pid):
dajax = Dajax()
if pid:
product = Product.objects.get(id=int(pid))
name = product.name
if request.user.user_type == 'A':
product.delete()
else:
product.is_delete = True
product.save()
history = ProductHistory()
history.product = product
history.person = request.user
history.act_type = 'DL'
history.description = "Delete product"
history.save()
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The <b> {0} </b> has been deleted successfully .'.format(name))
dajax.script("Success();")
return dajax.json()
示例11: add_sales_tax
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def add_sales_tax(request,states,rates):
dajax = Dajax()
print "Add Sale Taxes"
if isinstance(request.user,Staff) and request.user.user_type == 'A':
if states and rates:
print "List",states,rates
if len(states) == len(rates):
for x in range(0, len(states)):
print x,states[x],rates[x]
sale_tax = SaleTax()
sale_tax.state = states[x]
sale_tax.tax_amount = float(rates[x])
sale_tax.save()
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The sale tax has been added successfully .')
dajax.script("Success();")
else:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', "We're sorry, but something went wrong. Please be sure that you entered a valid form.")
dajax.script("Warning();")
else:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', "We're sorry, but something went wrong. Please be sure that you entered a valid form.")
dajax.script("Warning();")
return dajax.json()
示例12: general_settings
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def general_settings(request,short_limit,site_name,image_count,exchange_rate,duty_rate_factor,shipping_charge_default,margin_charge_default):
dajax = Dajax()
print "General settings Save - Solo Models"
if isinstance(request.user,Staff) and request.user.user_type == 'A':
print "hai"
if site_name and int(image_count) and int(short_limit) and float(exchange_rate) and float(duty_rate_factor) and float(shipping_charge_default) and float(margin_charge_default):
site_settings = SiteConfigurations.objects.get()
site_settings.site_name = site_name
site_settings.image_count = int(image_count)
site_settings.duty_rate_factor = duty_rate_factor
site_settings.exchange_rate = exchange_rate
site_settings.shipping_charge_default = shipping_charge_default
site_settings.margin_charge_default = margin_charge_default
site_settings.short_limit = short_limit
site_settings.save()
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The site global settings has been updated successfully .')
dajax.script("Success();")
else:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', "We're sorry, but something went wrong. Please be sure that you entered a valid form.")
dajax.script("Warning();")
return dajax.json()
示例13: delete_tax
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def delete_tax(request,tid):
dajax = Dajax()
print "Delete Sale Taxes"
if isinstance(request.user,Staff) and request.user.user_type == 'A':
if tid:
sale_tax = SaleTax.objects.get(id=tid)
state = sale_tax.state
sale_tax.delete()
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The state <b> {0} </b> has been deleted successfully .'.format(state))
dajax.script("Success();")
else:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', "We're sorry, but something went wrong. Please be sure that you entered a valid form.")
dajax.script("Warning();")
return dajax.json()
示例14: quick_view_photographer
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def quick_view_photographer(request,value=None):
print "hello inside the ajax"
dajax = Dajax()
if value:
try:
staff = Staff.objects.get(id=value)
dajax.assign('#ph_head', 'innerHTML', '')
dajax.assign('#ph_image', 'innerHTML', '')
dajax.assign('#ph_name', 'innerHTML', '')
dajax.assign('#ph_email', 'innerHTML', '')
dajax.assign('#ph_mobile', 'innerHTML', '')
dajax.assign('#ph_wechat', 'innerHTML', '')
dajax.assign('#ph_head', 'innerHTML', ''' <i class='fa fa-user'></i> {0} Profile'''.format(staff.get_full_name()))
dajax.assign('#ph_image', 'src', '{0}'.format(staff.image_display()))
dajax.assign('#ph_name', 'innerHTML','{0}'.format(staff.get_full_name()))
dajax.assign('#ph_email', 'innerHTML','{0}'.format(staff.email))
dajax.assign('#ph_mobile', 'innerHTML','{0}'.format(staff.mobile))
dajax.assign('#ph_wechat', 'innerHTML','{0}'.format(staff.we_chat))
dajax.script('QuickView();')
except Staff.DoesNotExist:
pass
return dajax.json()
示例15: get_compititor_avg
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import json [as 别名]
def get_compititor_avg(request,pid):
dajax = Dajax()
print "Inside Compititor Average PriceAvg "
if pid:
product = Product.objects.get(id=int(pid))
competitor_aveg = 0
avg = 0
com_sum = 0
if product.competitor.all():
for competitor in product.competitor.all():
com_sum = com_sum+competitor.price
avg = com_sum/product.competitor.all().count()
competitor_aveg=[product.competitor.all().count(),float(com_sum),avg]
print "competatior_avg",avg,competitor_aveg
dajax.assign('#compi_avg', 'value','{0}'.format(format(avg,'.2f')))
dajax.assign('#compi_count', 'value','{0}'.format(format(product.competitor.all().count(),'.2f')))
dajax.assign('#compi_sum', 'value','{0}'.format(format(com_sum,'.2f')))
dajax.script("updateCompetitorPrice();")
return dajax.json()