本文整理汇总了Python中apps.dajax.core.Dajax类的典型用法代码示例。如果您正苦于以下问题:Python Dajax类的具体用法?Python Dajax怎么用?Python Dajax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dajax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: savephone
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()
示例2: signup
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()
示例3: get_compititor_avg
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()
示例4: quick_view_faq
def quick_view_faq(request,value=None):
print "hello inside the ajax"
dajax = Dajax()
if value:
print 'sucesssssssss'
# 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()
示例5: delete_message
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()
示例6: delete_image
def delete_image(request,iid):
dajax = Dajax()
if iid:
ProductGallery.objects.get(id=int(iid)).delete()
dajax.script('CheckRemainingCount();')
return dajax.json()
示例7: delete_discount
def delete_discount(request,did):
dajax = Dajax()
if did:
discount = Discount.objects.get(id=did)
discount.delete()
dajax.script('Calculation();')
return dajax.json()
示例8: delete_slider
def delete_slider(request,value=None):
dajax = Dajax()
if isinstance(request.user,Staff) and request.user.user_type == 'A':
try:
slider = Slider.objects.get(id=value)
slider.delete()
dajax.script("LocationReload();")
except Slider.DoesNotExist:
pass
return dajax.json()
示例9: activate_reseller
def activate_reseller(request,rid):
dajax = Dajax()
reseller = Reseller.objects.get(id=int(rid))
reseller.is_active = True
reseller.save()
dajax.script("LocationReload();")
return dajax.json()
示例10: activate
def activate(request,sid):
dajax = Dajax()
staff = Staff.objects.get(id=int(sid))
staff.is_active = True
staff.save()
dajax.script("LocationReload();")
return dajax.json()
示例11: image_processing
def image_processing(request,iid,im_type):
dajax = Dajax()
print "Inside Add Image to Categories"
if im_type and iid:
image = ProductGallery.objects.get(id=iid)
image.image_type = im_type
image.save()
print "Saved"
return dajax.json()
示例12: get_discount
def get_discount(request,product):
dajax = Dajax()
product = get_object_or_404(Product, id=int(product))
dajax.assign('#discount_rows', 'innerHTML', '')
discounts = product.discount.all().order_by('-id')
if discounts:
for counter,discount in enumerate(discounts):
if discount.is_active():
dajax.append('#discount_rows', 'innerHTML','''
<tr id="dis{5}">
<td>{0}</td>
<td>{1}</td>
<td>{2}%</td>
<td>{3}</td>
<td>{4}</td>
<td><a class="btn btn-success btn-icon btn-circle"><i class="fa fa-check"></i></a></td>
<td>
<button type="button" onclick="DeleteDiscount({5});" class="btn btn-sm btn-warning"><i class="fa fa-trash"></i> Delete</button>
</td>
</tr>
'''.format(counter+1,discount.name,discount.discount,discount.effe_date.strftime("%d %b %Y"),discount.expi_date.strftime("%d %b %Y"),discount.id))
else:
dajax.append('#discount_rows', 'innerHTML','''
<tr id="dis{5}">
<td>{0}</td>
<td>{1}</td>
<td>{2}%</td>
<td>{3}</td>
<td>{4}</td>
<td><a class="btn btn-danger btn-icon btn-circle"><i class="fa fa-times"></i></a></td>
<td>
<button type="button" onclick="DeleteDiscount({5});" class="btn btn-sm btn-warning"><i class="fa fa-trash"></i> Delete</button>
</td>
</tr>
'''.format(counter+1,discount.name,discount.discount,discount.effe_date.strftime("%d %b %Y"),discount.expi_date.strftime("%d %b %Y"),discount.id))
dajax.script('ShowDiscountTable();')
return dajax.json()
示例13: get_shipping_rate
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()
示例14: deactivate_faq
def deactivate_faq(request,value=None):
dajax = Dajax()
if isinstance(request.user,Staff) and request.user.user_type == 'A' :
try:
faq = Faq.objects.get(id=value)
faq.is_active = False
faq.save()
dajax.script("LocationReload();")
except Faq.DoesNotExist:
pass
return dajax.json()
示例15: delete_product
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()