本文整理汇总了Python中misc.dajax.core.Dajax.remove_css_class方法的典型用法代码示例。如果您正苦于以下问题:Python Dajax.remove_css_class方法的具体用法?Python Dajax.remove_css_class怎么用?Python Dajax.remove_css_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc.dajax.core.Dajax
的用法示例。
在下文中一共展示了Dajax.remove_css_class方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_profile_password
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def edit_profile_password(request, form=None):
"""
Used to give Dajax(ice) the change password page
Renders in : modal
Refreshes : right_content
"""
dajax = Dajax()
errors = False
userprofile = request.user.get_profile()
fullname = userprofile.user.get_full_name()
nickname = userprofile.nickname
if request.method == 'POST' and form != None:
form = PasswordChangeForm(userprofile.user, deserialize_form(form))
if form.is_valid():
form.save()
dajax.remove_css_class('#profile_edit_form input', 'error')
dajax.script('modal_hide()') # Hide modal
show_alert(dajax, 'success', 'Password was changes successfully')
else:
errors = True
dajax.remove_css_class('#profile_edit_form input', 'error')
for error in form.errors:
dajax.add_css_class('#id_%s' % error, 'error')
print "errors :", [i for i in form.errors]
#show_alert(dajax, 'error', "There were errors in the form") # as it is in modal, not req
else:
form = PasswordChangeForm ( userprofile.user )
html_content = render_to_string("users/passwd_form.html", locals(), RequestContext(request))
dajax.assign("#id_modal", "innerHTML", html_content) # Populate modal
return dajax.json()
示例2: edit_profile
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def edit_profile(request, form=None):
"""
Used to give Dajax(ice) the edit profile page
Renders in : modal
Refreshes : right_content
"""
dajax = Dajax()
errors = False
userprofile = request.user.get_profile()
fullname = userprofile.user.get_full_name()
nickname = userprofile.nickname
if request.method == 'POST' and form != None:
form = EditProfileForm(deserialize_form(form), instance=userprofile)
if form.is_valid():
form.save()
dajax.assign("#edit_profile_nickname", "innerHTML", edit_form.cleaned_data['nickname'])
dajax.remove_css_class('#profile_edit_form input', 'error')
dajax.script('modal_hide()') # Hide modal
show_alert(dajax, 'success', 'Profile was edited and saved')
else:
errors = True
dajax.remove_css_class('#profile_edit_form input', 'error')
for error in form.errors:
dajax.add_css_class('#id_%s' % error, 'error')
#show_alert(dajax, 'error', "There were errors in the form") # as it is in modal, not req
else:
form = EditProfileForm ( instance = userprofile )
html_content = render_to_string("users/edit_profile.html", locals(), RequestContext(request))
#dajax.remove_css_class('#id_modal', 'hide') # Show modal (already done in do_Dajax)
dajax.assign("#id_modal", "innerHTML", html_content) # Populate modal
return dajax.json()
示例3: new_blog
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
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
示例4: contact_us
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def contact_us(request):
"""
Used to populate the Modal with Contact Us page
"""
dajax = Dajax()
html_content = render_to_string("common/contact_us.html", locals(), RequestContext(request))
dajax.remove_css_class('#id_modal', 'hide') # Show modal
dajax.assign("#id_modal", "innerHTML", html_content) # Populate modal
#print "added"
return dajax.json()
示例5: display_task
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def display_task(request, primkey, comments_field=None):
"""
Displays a task to viewers with a commet field
It handles the displaying of all tasks : intra and cross
The post method handles the receiving of a submitted comment and saves it
Renders in : modal
Refreshes : if new comment added, refreshed content of modal
"""
# TODO: Redirect people who aren't allowd to view this task.
# Add edit and delete buttons for cores and supercoords
# Display ALL details in the template - template needs work.
print primkey
dajax = Dajax()
html_content = ""
primkey = int(primkey)
# Save comment if new comment given
# Get Task + comments and populate
try:
task = Task.objects.get(pk = primkey)
task_statuses = TASK_STATUSES
print "task"
if request.method == 'POST' and comments_field != None: # Add new comment if necessary
if comments_field == "":
dajax.add_css_class("#comments_field", "error")
else :
task_comment = Comment()
task_comment.task = Task.objects.filter(id = task.id)[0]
task_comment.author = request.user
task_comment.comment_string = comments_field
task_comment.time_stamp = datetime.datetime.now()
task_comment.save()
print "check comment"
if ( comments_field != "" and comments_field != None ) or request.method == 'GET':
print "true"
# i.e. if "Submit Comment" was pressed, and comment was given OR GET ... need to refresh
comments = Comment.objects.filter(task = task)
html_content = render_to_string('tasks/display.html', locals(), RequestContext(request))
print html_content
dajax.remove_css_class('#id_modal', 'hide') # Show modal
dajax.assign("#id_modal", "innerHTML", html_content) # Populate modal
print "done"
except:
show_alert(dajax, "error", "The task was not found")
html_content = ""
return dajax.json()
示例6: roommap
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
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()
示例7: display_profile
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def display_profile(request, userid=None):
"""
Used to show profile using Dajax(ice)
Renders in : modal
Refreshes : none
"""
dajax = Dajax()
profile_dict = dict ()
profile_dict['userexists'] = True
html_content = ""
try:
if userid == None:
profile = request.user.get_profile()
else:
profile = ERPUser.objects.get ( pk = userid )
# Profile seems to exist, get data
userprofile = request.user.get_profile()
profile_dict['nickname'] = profile.nickname
profile_dict['position'] = get_position ( profile )
profile_dict['fullname'] = profile.user.get_full_name()
profile_dict['chennaino'] = profile.chennai_number
profile_dict['summerno'] = profile.summer_number
profile_dict['summerstay'] = profile.summer_stay
profile_dict['hostel'] = profile.hostel
profile_dict['roomno'] = str(profile.room_no)
#This is a flag which indicates that the profile being viewed is the user's own. Hence there will be
#a button to edit.
profile_dict['ownprofile'] = ( profile == userprofile )
# Render the template with given info
html_content = render_to_string('users/view_profile.html', profile_dict, RequestContext(request))
except:
# Profile given was invalid.
profile_dict['userexists'] = False
html_content = render_to_string('users/view_profile.html', locals(), RequestContext(request))
dajax.remove_css_class('#id_modal', 'hide') # Show modal
dajax.assign('#id_modal','innerHTML', html_content) # Populate modal
return dajax.json()
示例8: contactus
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def contactus(request, form = None):
"""
Handles the "contact us" form on the home page
"""
dajax = Dajax() # to hold dajax-json
if request.method == 'POST':
form = ContactRequestsForm(deserialize_form(form))
print form
if form.is_valid(): # check validity
form.save()
# @Ali: clear the form after saving it, the below command didnt do it, and make the send button pseud
#form = ContactRequestsForm()
show_alert(dajax, "success", "Your message has been submitted. We will get back to you shortly")
else: # form was not valid, show errors
dajax.remove_css_class('#form_footer_contactus 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
示例9: new_cross_task
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def new_cross_task(request, serializedform=None, primkey=None):
"""
Serves and processes a new intradepartmental task.
- if processing error, shows errors on same form
- if no error, shows success alert
CORES: (ONLY)
Have access to edit and add tasks
Arguments :
serializedform - in post request, the form is sent
primkey - prinkey of parent task (if any)
Fields entered by user:
'deadline', 'subject', 'description', 'parenttask', 'targetsubdepts'
Fields automatically taken care of by model/model save function override:
'taskcreator', 'datecreated', 'datelastmodified', 'depthlevel'
Fields taken care of by the view:
'origindept', 'targetdept', 'isxdepartmental', 'taskstatus'
Fields that are unset:
'taskforce'
"""
dajax = Dajax()
# Check parenttask and create parent-string
if primkey:
parenttask = Task.objects.get(pk=primkey)
parentlabel = "\nParent task: " + parenttask.subject
else:
parentlabel = "\nThis is a top level task."
parenttask = None
# Add some more basic info
title = "Add Cross-departmental Task."
info = "Subject to approval of the target department's core." + parentlabel
userprofile = request.user.get_profile()
department = userprofile.dept
id_form = "new_cross_task"
if request.method == 'POST' and serializedform != None:
form = CrossTaskForm(department, deserialize_form(serializedform))
if form.is_valid():
#Create a task object without writing to the database
newTask = form.save(commit=False)
#Get selected subdepartment from form and set targetdepartment
#There's only one object in the form field - the loop is only going to run once.
for subdept in form.cleaned_data['targetsubdepts']:
newTask.targetdept = subdept.dept
#Set these variables - Unapproved X-Departmental task
newTask.taskcreator = userprofile
newTask.isxdepartmental = True
newTask.taskstatus = 'U'
if primkey:
newTask.parenttask = parenttask
#Set the origin & target departments.
newTask.origindept = userprofile.dept
#For many to many relationships to be created, the object MUST first exist in the database
#Saves newTask and also saves the ManyToMany Data
newTask.save()
form.save_m2m() # Form saved
dajax.remove_css_class('#form_' + str(id_form) + ' input', 'error') # remove earlier errors mentioned
show_alert(dajax, 'success', "Task saved successfully") # show alert
else: # some errors found
errors = True
dajax.remove_css_class('#form_' + str(id_form) + ' 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
示例10: new_intra_task
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def new_intra_task(request, serializedform=None, primkey=None):
"""
Serves and processes a new intradepartmental task.
- if processing error, shows errors on same form
- if no error, shows success alert
CORES and SUPERS :
Have access to edit and add tasks
Arguments :
serializedform - in post request, the form is sent
primkey - prinkey of parent task (if any)
Fields entered by user:
'deadline', 'subject', 'description', 'taskforce'
Fields automatically taken care of by model/model save function override:
'taskcreator', 'datecreated', 'datelastmodified', 'depthlevel', 'parenttask'
Fields taken care of by the view:
'targetsubdepts', 'origindept', 'targetdept', 'isxdepartmental', 'taskstatus'
"""
dajax = Dajax()
print ("Primkey: %s" % primkey)
# Check parent task and create parent-string
if primkey:
# Need to figure out the try, except block here
parenttask = Task.objects.get(pk=primkey)
parentlabel = "\nParent task: " + parenttask.subject
else:
parentlabel = "\nThis is a top level task."
parenttask = None
# Get basic data
id_form = "new_task"
userprofile = request.user.get_profile()
department = userprofile.dept
title = "Add Intradepartmental Task"
info = parentlabel
if request.method == 'POST' and serializedform != None:
form = IntraTaskForm(department, deserialize_form(serializedform)) # get form
if form.is_valid(): # check validity
newTask = form.save(commit=False)
#Set the origin & target departments & approve the task.
newTask.origindept = userprofile.dept
newTask.targetdept = userprofile.dept
newTask.taskcreator = userprofile
newTask.taskstatus = 'O'
newTask.parenttask = parenttask
#For many to many relationships to be created, the object MUST first exist in the database.
newTask.save()
#UNCOMMENT THE BELOW LINE IF MANYTOMANY DATA IS BEING SAVED DIRECTLY FROM THE FORM
#form.save_m2m()
#Get the TaskForce from the form
cores = form.cleaned_data['cores']
coords = form.cleaned_data['coords']
supercoords = form.cleaned_data['supercoords']
#Set the TaskForce for the Task
for user in coords:
newTask.taskforce.add(user)
for user in supercoords:
newTask.taskforce.add(user)
for user in cores:
newTask.taskforce.add(user)
newTask.save() # task saved
dajax.remove_css_class('#form_' + str(id_form) + ' input', 'error') # remove earlier errors mentioned
show_alert(dajax, 'success', "Task saved successfully") # show alert
else: # some errors found
errors = True
dajax.remove_css_class('#form_' + str(id_form) + ' 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
示例11: edit_tab
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def edit_tab(request, tab_pk=None, event_pk=None, edit_form=None, delete_tab=None):
"""
This function renders the "edit event" page for Event coords
args :
tab_pk - the pk of the tab being edited
form - the form sent in post request
event_pk - pk of event the tab belongs to. must exist.
delete_tab - indicates whether to delete the tab or not
Check before savin
- check if name changed, if yes : change file name
In the form :
event - got from event_pk
title, desc, pref - got from form
"""
dajax = Dajax()
html_content = ""
new_tab_created = False
if tab_pk:
tab_instance = Tab.objects.get(pk=tab_pk)
else:
tab_instance = None
if event_pk:
generic_event_instance = GenericEvent.objects.get(pk=event_pk)
event_type = generic_event_instance.event_type
if event_type=='Participant':
event_instance = ParticipantEvent.objects.get(pk=event_pk)
elif event_type=='Audience':
event_instance = AudienceEvent.objects.get(pk=event_pk)
else:
show_alert(dajax, "error", "There is some error with this event. Contact the WebOps team.")
return dajax.json()
else:
show_alert(dajax, "error", "There is some problem with this tab. Contact WebOps team.")
return dajax.json()
if request.method == 'POST' and edit_form != None:
if tab_instance: # Old tab being edited
form = TabDetailsForm(deserialize_form(edit_form), instance = tab_instance)
tab_name_old = tab_instance.title
else: # New tab
form = TabDetailsForm(deserialize_form(edit_form))
new_tab_created = True
if form.is_valid(): # Save form and json
clean_form = form.clean()
# Handles the form and sql
try:
form.save(event_inst = event_instance)
except EditError as error:
show_alert(dajax, "error", error.value)
return dajax.json()
# change tab name if it has changed
if tab_instance:
tab_name_new = clean_form['title']
if tab_name_new != tab_name_old: # Change tab title
dajax.assign("#a_tab_" + str(tab_instance.pk), "innerHTML", tab_name_new)
if new_tab_created:
# Note : need to make this better. Currently, it'll refresh the whole left content. It's better to add what's required only...
dajax.script("$('#list_eventpage_eventinfo').find('a').click();")
dajax.remove_css_class('#id_form input', 'error')
show_alert(dajax, "success", "Tab edited successfully")
else:
error_string = "<br />"
dajax.remove_css_class('#id_form input', 'error')
for error in form.errors:
error_string += error[0].upper() + error[1:] + ": " + form.errors[error][0] + "<br />"
dajax.add_css_class('#id_%s' % error, 'error')
form = TabDetailsForm()
show_alert(dajax, "error", error_string)
#html_content = render_to_string('events/edit_tab.html', locals(), RequestContext(request)) # show edit form again
elif request.method == 'POST' and delete_tab == 'delete':
if tab_instance:
try:
tab_instance.delete()
except EditError as error:
show_alert(dajax, "error", error.value)
return dajax.json()
# Note : need to make this better. Currently, it'll refresh the whole left content. It's better to add what's required only...
show_alert(dajax, "success", "Tab deleted successfully")
dajax.script("$('#list_eventpage_eventinfo').find('a').click();")
else:
show_alert(dajax, "error", "There is some problem with deleting this tab. Contact the WebOps Team.")
return dajax.json()
else:
if tab_instance:
form = TabDetailsForm(instance = tab_instance)
else:
form = TabDetailsForm()
context_dict = {'model_instance' : tab_instance, 'type' : 'tab', 'tab_event_pk': event_pk, 'form' : form}
html_content = render_to_string('events/edit_form.html', context_dict, RequestContext(request))
#.........这里部分代码省略.........
示例12: edit_event
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def edit_event(request, event_name=None, event_pk=None, edit_form=None):
"""
This function renders the "edit event" page for Event coords
args :
event_name - The name of the event which needs to be edited
event_pk - The pk of the event which needs to be edited
edit_Form - The edited form in post requests
Check before savin
- check if name changed, if yes : change file name
An existing event can be either audience or participant event.
If new event is being created, a GenericEventForm is displayed, and it can be saved with event type as audience or participant event.
"""
dajax = Dajax()
html_content = ""
event_query = None
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_pk:
event_query = GenericEvent.objects.filter(pk=event_pk)
elif event_name:
event_query = GenericEvent.objects.filter(title=event_name)
if event_query: # get event details and tab details
generic_event_instance = event_query[0]
event_pk = generic_event_instance.pk
event_type = generic_event_instance.event_type
if event_type=='Participant':
event_instance = ParticipantEvent.objects.get(pk=event_pk)
elif event_type=='Audience':
event_instance = AudienceEvent.objects.get(pk=event_pk)
else: #if no event type -- show error
show_alert(dajax, "error", "There is some error with this event. Contact the WebOps team.")
return dajax.json()
if request.method == 'POST' and edit_form != None:
if event_instance:
if event_type=='Participant':
form = ParticipantEventDetailsForm(deserialize_form(edit_form), instance = event_instance)
elif event_type=='Audience':
form = AudienceEventDetailsForm(deserialize_form(edit_form), instance = event_instance)
#form = EventDetailsForm(deserialize_form(edit_form), instance = event_instance)
event_name_old = event_instance.title
else:
form = GenericEventDetailsForm(deserialize_form(edit_form))
if form.is_valid(): # Save form and json
clean_form = form.clean()
# Handles the form and sql
try:
form.save()
except EditError as error:
show_alert(dajax, "error", error.value)
return dajax.json()
# check if event name has changed, change the event - tab title if yes.
if event_instance:
event_name_new = clean_form['title']
if event_name_new != event_name_old: # Change event - tab title
dajax.assign("#a_event_" + str(event_instance.pk), "innerHTML", event_name_new)
dajax.remove_css_class('#id_form input', 'error')
show_alert(dajax, "success", "Event edited successfully")
else:
error_string = "<br />"
dajax.remove_css_class('#id_form input', 'error')
for error in form.errors:
error_string += error[0].upper() + error[1:] + ": " + form.errors[error][0] + "<br />"
dajax.add_css_class('input#id_%s' % error, 'error')
if event_instance:
if event_type=='Participant':
form = ParticipantEventDetailsForm()
elif event_type=='Audience':
form = AudienceEventDetailsForm()
else:
form = GenericEventDetailsForm()
show_alert(dajax, "error", error_string)
#html_content = render_to_string('events/edit_event.html', locals(), RequestContext(request)) # show edit form again
else:
if event_instance:
if event_type=='Participant':
form = ParticipantEventDetailsForm(instance = event_instance)
elif event_type=='Audience':
form = AudienceEventDetailsForm(instance = event_instance)
#form = EventDetailsForm(instance = event_instance)
else:
form = GenericEventDetailsForm()
context_dict = {'model_instance' : event_instance, 'type' : 'event', 'form' : form}
html_content = render_to_string('events/edit_form.html', context_dict, RequestContext(request))
if html_content:
if event_instance:
#.........这里部分代码省略.........
示例13: register
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def register(request,form_registration=None,college_name=None):
#logged in user cannot register, but just in case
dajax = Dajax()
college = None
new_coll = False
if not college_name is None:
try:
college=College.objects.filter(name=str(college_name))[0]
new_coll = True
except:
#impossible scenario!!
dajax.script("$.bootstrapGrowl('You must have entered your college first!', {type:'danger',delay:10000});")
dajax.script('$("#gif_registration").hide();$("#form_registration_submit").show()')
return dajax.json()
if request.user.is_authenticated():
msg_login = '%s, You are already logged in!!' % request.user.username
dajax.script('$.bootstrapGrowl("Hi %s" , {type:"danger",delay:10000} );'% msg_login )
dajax.script('$("#gif_registration").hide();$("#form_registration_submit").show()')
return dajax.json()
if request.method=="POST" and (form_registration !=None or not college_name is None):
form = AddUserForm(deserialize_form(form_registration))
if form.is_valid():
#TODO: if we change college to be a compulsory, then this must be changed
dajax.remove_css_class('#form_registration input', 'error')
data = form.cleaned_data
new_user = User(first_name=data['first_name'],last_name=data['last_name'], username=data['username'], email=data['email'])
new_user.set_password(data['password'])
new_user.save()
new_user.is_active = True
new_user.save()
x = 1400000 + new_user.id
salt = sha.new(str(random.random())).hexdigest()[:5]
activation_key = sha.new(salt + new_user.username).hexdigest()
if college is None:
userprofile = UserProfile(user=new_user,activation_key=activation_key,gender=data['gender'],age=data['age'],branch=data['branch'],mobile_number=data['mobile_number'],college=data['college'],college_roll=data['college_roll'],shaastra_id= ("SHA" + str(x)),key_expires = timezone.now()+datetime.timedelta(2))
else:
userprofile = UserProfile(user=new_user,activation_key=activation_key,gender=data['gender'],age=data['age'],branch=data['branch'],mobile_number=data['mobile_number'],college=college,college_roll=data['college_roll'],shaastra_id= ("SHA" + str(x)),key_expires = timezone.now()+datetime.timedelta(2))
userprofile.save()
#mail_template = get_template('email/activate.html')
#body = mail_template.render( Context( {
# 'username':new_user.username,
# 'activationkey':userprofile.activation_key,
# 'SITE_URL':settings.SITE_URL,
# 'shaastra_id':userprofile.shaastra_id,
# }))
#TODO: empty the entire form!!
#dajax.script("$('#form_registration').val('');")\
#dajax.script("$('#form_registration #id_email').val('');\
# $('#form_registration #id_password').val('');\
# $('#form_registration #id_password_again').val('');\
# $('#form_registration #id_mobile_number').val('');")
#if settings.SEND_EMAILS:
#subject, from_email, to = 'Your new Shaastra2014 account confirmation', '[email protected]', [new_user.email,]
#html_content = body
#text_content = strip_tags(body)
#msg = EmailMultiAlternatives(subject, text_content, from_email, to)
#msg.attach_alternative(html_content, "text/html")
#msg.send()
#send_mail('Your new Shaastra2014 account confirmation', body,'[email protected]', [new_user.email,], fail_silently=False)
#msg='Hi, A mail has been sent to the mail id you provided. Please activate your account within 48 hours. Please also check your spam folder'
msg = 'Successfully Registered ! <br /> Welcome !'
# dajax.script('$(".modal-header").find(".close").click();')
dajax.script('$.bootstrapGrowl("%s" , {type:"success",delay:20000} );'% msg )
dajax.script('$("#gif_registration").hide();$("#form_registration_submit").show();$("#login").modal("hide")')
dajax.script('$("#form_registration #id_college_roll").attr("readonly", false);$("#form_registration #id_college_roll").val("");')
return dajax.json()
else:
errdict=dict(form.errors)
dajax.script('$.bootstrapGrowl("Oops : Following errors cropped up when you tried to register !", {type:"danger",timeout:50000} );')
for error in form.errors:
if str(errdict[error][0])!='This field is required.':
dajax.script('$.bootstrapGrowl(" %s" , {type:"error",delay:20000} );'% str(errdict[error][0]))
dajax.script("$('#form_registration #id_password').val('');")
dajax.script("$('#form_registration #id_password_again').val('');")
for error in form.errors:
dajax.add_css_class('#form_registration #id_%s' % error, 'error')
dajax.script('$("#gif_registration").hide();$("#form_registration_submit").show()')
return dajax.json()
if request.method == 'GET':
form_registration = AddUserForm()
dajax.script('$("#gif_registration").hide();$("#form_registration_submit").show()')
return dajax.json()
form_registration=AddUserForm()
dajax.script('$("#gif_registration").hide();$("#form_registration_submit").show()')
return dajax.json()
示例14: login
# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import remove_css_class [as 别名]
def login(request,login_form = None):
dajax = Dajax()
if request.user.is_authenticated():
msg_login='%s, You are logged in!!' % request.user.username
dajax.script('$.bootstrapGrowl("%s", {type:"danger",delay:20000} );'% msg_login )
dajax.script('$(".modal-header").find(".close").click()')
return dajax.json()
elif request.method == 'POST' or login_form != None:
form = LoginForm(deserialize_form(login_form))
if form.is_valid() :
data=form.cleaned_data
username=data['username']
password=data['password']
user = authenticate(username=username, password=password)
if user:
if not user.is_active:
msg = 'Please click the activation link sent to your registered email id to activate your account'
dajax.script('$.bootstrapGrowl("%s", {type:"danger",delay:30000} );' % msg)
dajax.script("$('#login_form #id_password').val('');")
return dajax.json()
auth_login(request, user)
dajax.script('$.bootstrapGrowl("Hi %s" , {type:"success",delay:10000} );'% user.username )
dajax.script("$('#login_form #id_password').val('');")
dajax.script("$('#login').modal('hide');")
dajax.script('$(".modal-header").find(".close").click()')
dajax.script('$("#fb_share").modal("show");')
profile = UserProfile.objects.get(user=request.user)
context_dash_dict = {'profile':profile,'settings':settings}
html_stuff = render_to_string('dashboard/welcome.html',context_dash_dict,RequestContext(request))
dajax.script("window.location.hash = 'dashboard'")
if html_stuff:
dajax.assign('#content_dash','innerHTML',html_stuff)
# dajax.script('$(\"#list_user_head a\").click();')
#dajax.script('$(\"#list_events_head a\").click();')
#dajax.script('javascript:do_accordion(\"list_user\");')
# dajax.script("javascript:do_accordion('list_user')")
dajax.script("$('#aboutus').hide();")
dajax.assign("#dashboard #dashboard_shaastra_id","innerHTML",str(request.user.get_profile().shaastra_id))
dajax.assign("#dashboard #dashboard_full_name","innerHTML",str(request.user.get_full_name()))
dajax.assign("#login_logout", "innerHTML",'<div class="btn-group">\
<button class="btn" onclick ="window.location.replace(\'#dashboard\');\
"><i class="icon-user icon-white"></i>My Dashboard \
</button></div>')
dajax.remove_css_class("#dashboard","hide hidden")
#display logout| edit profile on navbar
return dajax.json()
else:
msg = 'Username and Password does not match!!!'
if User.objects.filter(username=username).count()==0:
msg = 'Username not created, did you want to register?'
dajax.script('$.bootstrapGrowl("%s", {type:"danger",delay:20000} );' % msg)
dajax.script("$('#login_form #id_password').val('');")
form = LoginForm()
form_registration = AddUserForm()
return dajax.json()
else:
dajax.remove_css_class('#my_form input', 'error')
for error in form.errors:
dajax.add_css_class('#login_form #id_%s' % error, 'error')
return dajax.json()
#Code for error rendering
else:
dajax.script('$.bootstrapGrowl("Fill in required details", {type:"danger",delay:20000} );')
#empty form case
return dajax.json()
return dajax.json()