本文整理汇总了Python中apps.dajax.core.Dajax.script方法的典型用法代码示例。如果您正苦于以下问题:Python Dajax.script方法的具体用法?Python Dajax.script怎么用?Python Dajax.script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.dajax.core.Dajax
的用法示例。
在下文中一共展示了Dajax.script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_discount
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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: edit_slider_content
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例3: add_category
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [as 别名]
def add_category(request,name,lang):
dajax = Dajax()
print "Inside Add Category",lang,name
if name:
node = Category()
try:
if lang == 'zh':
print "Chinese"
node.name = name
node.name_zh = name
else:
print "English"
node.name = name
node.save()
print "Save"
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The <b> {0} </b> has been added successfully .'.format(name))
dajax.script("Success();")
except:
dajax.assign('#warning-head', 'innerHTML', '<strong>Warning!</strong>')
dajax.assign('#warning-body', 'innerHTML', "The Category <b> {0} </b> already exist".format(name))
dajax.script("Warning();")
return dajax.json()
示例4: remove_phone
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例5: quick_view_photographer
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例6: get_shipping_rate
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例7: edit_sales_tax
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例8: add_subcategory
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [as 别名]
def add_subcategory(request,cid,name,lang):
dajax = Dajax()
print "Inside Add SubCategory"
if cid:
cate = Category.objects.get(id=cid)
node = Category()
node.parent = cate
print "Parent Category",cate
try:
if lang == 'zh':
print "Chinese"
node.name = name
node.name_zh = name
else:
print "English"
node.name = name
node.save()
print "Save"
dajax.assign('#success-head', 'innerHTML', '<strong>Success!</strong>')
dajax.assign('#success-body', 'innerHTML', 'The <b> {0} </b> has been added successfully .'.format(name))
dajax.script("Success();")
except Exception, e:
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();")
示例9: get_compititor_avg
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例10: delete_tax
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例11: general_settings
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例12: savephone
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例13: delete_product
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [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()
示例14: delete_image
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [as 别名]
def delete_image(request,iid):
dajax = Dajax()
if iid:
ProductGallery.objects.get(id=int(iid)).delete()
dajax.script('CheckRemainingCount();')
return dajax.json()
示例15: delete_discount
# 需要导入模块: from apps.dajax.core import Dajax [as 别名]
# 或者: from apps.dajax.core.Dajax import script [as 别名]
def delete_discount(request,did):
dajax = Dajax()
if did:
discount = Discount.objects.get(id=did)
discount.delete()
dajax.script('Calculation();')
return dajax.json()