本文整理汇总了Python中misc.dajax.core.Dajax类的典型用法代码示例。如果您正苦于以下问题:Python Dajax类的具体用法?Python Dajax怎么用?Python Dajax使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dajax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addroom
def addroom(request,addroom_form=None):
dajax = Dajax()
if request.method == 'POST' and addroom_form != None:
form = AddRoomForm(deserialize_form(addroom_form))
if form.is_valid():
cleaned_form = form.cleaned_data
room_num = cleaned_form['room_no']
hostel = cleaned_form['hostel']
already_avail = AvailableRooms.objects.filter(room_no=room_num,hostel=hostel)
if already_avail:
show_alert(dajax,"error","Room already exists")
return dajax.json()
else:
try:
form.save()
show_alert(dajax,"success","Room Added Successfully")
html_content = render_to_string('hospi/AddRoom.html',locals(),RequestContext(request))
dajax.assign('#tab2',"innerHTML",html_content)
return dajax.json()
except EditError as error:
show_alert(dajax,"error",error.value)
return dajax.json()
else:
show_alert(dajax,"error","Form is invalid")
return dajax.json()
else:
form = AddRoomForm()
html_content = render_to_string('hospi/AddRoom.html',locals(),RequestContext(request))
dajax.assign('#tab2',"innerHTML",html_content)
return dajax.json()
示例2: hello_world
def hello_world(request):
"""
Used for testing Dajax + Dajaxice
"""
dajax = Dajax()
dajax.assign('#id_content','innerHTML', "Hello world !")
#dajax.alert("Hello World!")
return dajax.json()
示例3: roommap
def roommap(request,hostel_name):
dajax = Dajax()
hostel_selected = AvailableRooms.objects.filter(hostel=hostel_name).order_by('room_no')
html_content = render_to_string('hospi/RoomMap.html', locals(),RequestContext(request))
dajax.remove_css_class=('#id_modal','hide')
dajax.assign('#id_modal',"innerHTML",html_content)
return dajax.json()
示例4: logout
def logout(request,**kwargs):
dajax = Dajax()
auth_logout(request)
dajax.script('$.bootstrapGrowl("Successfully logged out!", {type:"success",delay:10000});' )
dajax.assign("#login_logout", "innerHTML", '<a href="#login" onclick="$(\'#login\').modal(\'show\');">Login | Sign Up </a>')
dajax.add_css_class("#dashboard","hide hidden")
dajax.script("window.location.hash = 'events';")
return dajax.json()
示例5: hello
def hello(request, form=None):
"""
Test dajax
"""
dajax = Dajax()
dajax.alert("got from dajax");
return dajax.json()
示例6: contacts
def contacts(request):
"""
Used to show table of all members participating in shaastra
It creates a table for this.
Renders in : right_content
Refreshes : null
EVERYONE :
It can be seen by anyone who has signed in
QUERIES TO RETRIEVE:
1. Every user's:
> Name
> Department
> Designation
> Contact
> Link to profile
"""
dajax = Dajax() # To hold the json
userprofile = request.user.get_profile()
# Query dictionary will contain UserProfile and the table to be drawn
query_dictionary = {} # Initialize a blank Query dictionary.
query_dictionary["userprofile"] = userprofile
query_dictionary["TASK_STATUSES"] = TASK_STATUSES # To search for status msg
html_content = ""
# ALL QUERYSETS OF TASKS FILTERED FOR THE USER MUST BE AGAIN FILTERED BY DEPARTMENT (the way I've done it for user_tasks). THIS HANDLES THE MULTIPLE IDENTITY DISORDER.
# Assigning the above values
# ALL
all_users = ERPUser.objects.all()
query_dictionary["users_info"] = []
for u in all_users:
user_info = {
'iden' : u.id,
'name' : u.user.first_name + " " + u.user.last_name,
'dept' : u.get_dept_subdept(),
'desig' : u.get_position(),
'ph_mad' : u.chennai_number,
'ph_home' : u.summer_number,
'email' : u.user.email
}
query_dictionary['users_info'].append(user_info)
html_content = render_to_string("dash/contacts.html", query_dictionary, RequestContext(request))
if html_content != "":
# put html generated above into json if not null
# if null, alert has already been taken care of
dajax.assign('#id_content_right','innerHTML', html_content)
return dajax.json()
示例7: register
def register(request,reg_form=None,coll_form=None):
dajax=Dajax()
if request.method=='POST':
form = RegistrationForm(deserialize_form(reg_form))
collegeform = CollegeForm(deserialize_form(coll_form))
if form.is_valid():
if not collegeform.is_valid():
collist = form.cleaned_data['college'].split('|')
collquery = College.objects.using(mainsite_db).filter(name = collist[0],city=collist[1], state=collist[2])
if collquery.count():
college=collquery[0]
else:
college = College(name=collist[0],city=collist[1],state=collist[2])
college.save(using='mainsite')
else:
college = collegeform.instance
college.save(using='mainsite')
cleaned_form = form.cleaned_data
shaastraid = cleaned_form['shaastra_id']
if not id_in_db(shaastraid):
new_user = User(first_name=cleaned_form['first_name'],last_name=cleaned_form['last_name'],username=cleaned_form['username'],email=cleaned_form['email'])
new_user.set_password('default')
new_user.is_active = True
new_user.save(using='mainsite')
userprofile = UserProfile(user=new_user,
gender = cleaned_form['gender'],
branch = cleaned_form['branch'],
age = cleaned_form['age'],
mobile_number = cleaned_form['mobile_number'],
college_roll = cleaned_form['college_roll'],
college = college,
shaastra_id = shaastraid,
)
userprofile.save(using='mainsite')
else:
userprofile = get_userprofile(shaastraid)
userprofile.gender = cleaned_form['gender']
userprofile.branch = cleaned_form['branch']
userprofile.age = cleaned_form['age']
userprofile.mobile_number = cleaned_form['mobile_number']
userprofile.college_roll = cleaned_form['college_roll']
userprofile.college = college
userprofile.save(using='mainsite')
new_form = IndividualForm(initial={'shaastra_ID':shaastraid})
html_content = render_to_string('hospi/Checkin_form.html',locals(),RequestContext(request))
dajax.assign('#tab3',"innerHTML",html_content)
return dajax.json()
else:
show_alert(dajax,"error","Form is invalid")
return dajax.json()
示例8: alerter
def alerter(request,**kwargs):
print 'sssssssssssssssssss\n\n\n\n\n'
dajax=Dajax()
try:
col=College(name=text1,city=text2,state=text3)
col.save()
#form['college']=col
except:
col=College.objects.get(name=text1)
dajax.alert("Your college is already present")
#return dajax.json()
return simplejson.dumps({'message':'Added your college:: %s'% text1,'col':col})
示例9: view_tdp
def view_tdp(request,event_pk=None):
dajax = Dajax()
#get tdp objects from mainsite code
#import get_tdp_event on top and this takes in event as argument
#display in a table name and path to file
event = ParticipantEvent.objects.get(pk=event_pk)
tdplist = []
for tdp in TDP.objects.using(mainsite_db).filter(teamevent__event_id = event_pk):
tdplist.append((tdp,tdp.teamevent.team_id))
html_content = render_to_string('events/view_tdp.html',locals(),RequestContext(request))
dajax.assign('#id_content_right','innerHTML',html_content)
return dajax.json()
示例10: choose
def choose(request,choose_eventform=None):
dajax=Dajax()
if request.method=='POST' and choose_eventform != None:
form = ChooseEventForm(deserialize_form(choose_eventform))
if form.is_valid():
clean_form = form.clean()
event_name = clean_form['event']
generic_event_instance = GenericEvent.objects.get(title = event_name)
event_pk = generic_event_instance.pk
parti_event_instance = ParticipantEvent.objects.get(pk = event_pk)
mins = parti_event_instance.team_size_min
maxs = parti_event_instance.team_size_max
teamformset = formset_factory(ShaastraIDForm,extra=maxs)
data={
'form-TOTAL_FORMS':u'',
'form-INITIAL_FORMS':u'',
'form-MIN_NUM_FORMS':u'',
'form-MAX_NUM_FORMS':u'',
}
html_content = render_to_string('hospi/CreateTeam.html',locals(),RequestContext(request))
dajax.assign('#tab6',"innerHTML",html_content)
return dajax.json()
else:
show_alert(dajax,"error","Form invalid")
return dajax.json()
else:
form = ChooseEventForm()
html_content = render_to_string('hospi/Choose.html',locals(),RequestContext(request))
dajax.assign('#tab6',"innerHTML",html_content)
return dajax.json()
示例11: select_event_type
def select_event_type(request, event_name=None, event_pk=None, event_type_selected=None):
"""
This function changes type of the event from GenericEvent to Audience or Participant event based on input from the coord
You can query based on name or pk.
"""
dajax = Dajax()
json_dict = {}
event_instance = None
# Argument validation
if not ( event_name or event_pk ): # Neither arg given
show_alert(dajax, "error", "There is some error on the site, please report to WebOps team")
return dajax.json()
elif event_name and event_pk: # Both args given ..
show_alert(dajax, "error", "There is some error on the site, please report to WebOps team.")
return dajax.json()
elif event_pk:
event_query = GenericEvent.objects.filter(pk=event_pk)
elif event_name:
event_query = GenericEvent.objects.filter(title=event_name)
if event_query:
generic_event_instance = event_query[0]
event_pk = generic_event_instance.pk
event_instance = GenericEvent.objects.get(pk=event_pk)
else:
show_alert(dajax, "error", "This event has not been created on the site. Contact WebOps team.")
return dajax.json()
if event_type_selected:
if event_type_selected=='Participant':
p_event_instance = ParticipantEvent()
p_event_instance.pk = event_instance.pk
p_event_instance.title = event_instance.title
p_event_instance.category = event_instance.category
p_event_instance.event_type = 'Participant'
p_event_instance.save()
request.user.get_profile().event = p_event_instance
#form = ParticipantEventDetailsForm(deserialize_form(edit_form), instance = event_instance)
elif event_type_selected=='Audience':
a_event_instance = AudienceEvent()
a_event_instance.pk = event_instance.pk
a_event_instance.title = event_instance.title
a_event_instance.category = event_instance.category
a_event_instance.event_type = 'Audience'
a_event_instance.save()
request.user.get_profile().event = a_event_instance
dajax.script("location.reload();")
else:
context_dict = {'model_instance' : event_instance}
html_content = render_to_string('events/select_event_type.html', context_dict, RequestContext(request))
dajax.assign("#id_content_right", "innerHTML", html_content) # Populate content
return dajax.json()
示例12: choose_event_parti
def choose_event_parti(request,choose_form=None):
dajax=Dajax()
if request.method=="POST" and choose_form != None:
form=ChooseEventForm(deserialize_form(choose_form))
if form.is_valid():
clean_form = form.clean()
event_name = clean_form['event']
generic_event_instance = GenericEvent.objects.get(title=event_name)
event_pk = generic_event_instance.pk
teameventlist = TeamEvent.objects.using(mainsite_db).filter(event_id = event_pk)
userlist = []
for team in teameventlist:
userlist.append([team.users.all(),team.team_name])
#if exportCSV:
#response = HttpResponse(content_type='text/csv')
#response['Content-Disposition'] = 'attachment; filename="participants.csv'
#writer = csv.writer(response)
#writer.writerow(['Name','Username','Email','Mobile','Team Name','College','Shaastra ID','Want Accomodation'])
#for user1,team_name in userlist:
#for all_users in user1:
# writer.writerow([all_users.first_name,all_users.username,all_users.email,all_users.userprofile_set.all()[0].mobile_number,team_name, all_users.userprofile_set.all()[0].college,all_users.userprofile_set.all()[0].shaastra_id,all_users.userprofile_set.all()[0].want_accomodation])
html_content = render_to_string('events/coreshow_reg_part.html',locals(),RequestContext(request))
dajax.assign('#id_content_right','innerHTML',html_content)
return dajax.json()
else:
form=ChooseEventForm()
html_content = render_to_string('events/choose_event_reg_part.html',locals(),RequestContext(request))
dajax.assign('#id_content_right','innerHTML',html_content)
return dajax.json()
示例13: new_blog
def new_blog(request, form=None):
"""
Handles the creation of a blog post
- if user not logged in, give alert
Populates : Features
Removes : Showcase, Sponsors
"""
dajax = Dajax()
html_content = ""
dajax.add_css_class("#showcase", "hide")
dajax.add_css_class("#sponsors", "hide")
if request.method == "POST":
form = ThreadForm(deserialize_form(form))
print form
if form.is_valid(): # check validity
form.save()
show_alert(dajax, "success", "Your post has been saved !")
else: # form was not valid, show errors
dajax.remove_css_class("#form_new_blog_post input", "error")
for error in form.errors: # tell which parts had errors
dajax.add_css_class("#id_%s" % error, "error")
print [error for error in form.errors]
show_alert(dajax, "error", "There were some errors : please rectify them") # show alert
示例14: show_event_list
def show_event_list(request,choose_form = None):
dajax = Dajax()
if request.method == 'POST' and choose_form != None:
form = ChooseEventForm(deserialize_form(choose_form))
if form.is_valid():
#Basically emulating show_event_erp without checking for errors
clean_form = form.clean()
event_name = clean_form['event']
generic_event_instance = GenericEvent.objects.get(title = event_name)
event_type = generic_event_instance.event_type
event_pk = generic_event_instance.pk
if event_type == 'Participant':
event_instance = ParticipantEvent.objects.get(pk=event_pk)
form = ParticipantEventDetailsForm(instance = event_instance)
if event_type == 'Audience':
event_instance = AudienceEvent.objects.get(pk=event_pk)
form = AudienceEventDetailsForm(instance = event_instance)
tab_list = Tab.objects.filter(event=event_instance)
#context_dict = {'model_instance' : event_instance, 'type' : 'tab', 'form' : form}
html_content = render_to_string('events/erp_tabs.html', locals(), RequestContext(request))
dajax.assign("#id_content_right", "innerHTML", html_content)
return dajax.json()
else:
show_alert(dajax,"error","No content has been uploaded for this event")
else:
form = ChooseEventForm()
html_content = render_to_string('events/choose_event.html', locals(),RequestContext(request))
dajax.assign('#id_content_right','innerHTML', html_content)
return dajax.json()
示例15: change_password_form
def change_password_form(request):
dajax = Dajax()
dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")
#: if user has chosen a college in dropdown, depopulate it OR growl
if not request.user.is_authenticated():
dajax.script('$.bootstrapGrowl("Login First!", {type:"danger",delay:10000} );')
return dajax.json()
profile = UserProfile.objects.get(user=request.user)
change_password_form = ChangePasswordForm()
context_dict = {'form_change_password':change_password_form,'profile':profile,'settings':settings}
html_stuff = render_to_string('dashboard/change_password.html',context_dict,RequestContext(request))
if html_stuff:
dajax.assign('#content_dash','innerHTML',html_stuff)
#dajax.script('$("#event_register").modal("show");')
return dajax.json()