当前位置: 首页>>代码示例>>Python>>正文


Python Dajax.script方法代码示例

本文整理汇总了Python中misc.dajax.core.Dajax.script方法的典型用法代码示例。如果您正苦于以下问题:Python Dajax.script方法的具体用法?Python Dajax.script怎么用?Python Dajax.script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在misc.dajax.core.Dajax的用法示例。


在下文中一共展示了Dajax.script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: forgot_password

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def forgot_password(request,email=None):
    dajax = Dajax()
    if not email is None and not email == '' :
        try:
            validate_email(email)
#            validate_email is a django inbuilt function that throws ValidationError for wrong email address
#            Issue: starts with _ not acceptable
            profile = UserProfile.objects.get(user__email = str(email))
            email = profile.user.email
            user = profile.user
            if not profile.user.is_active:
                dajax.script('$.bootstrapGrowl("Activate your account first! Check your mail for the activation link." , {type:"error",delay:20000} );')
                return dajax.json()
            mail_template = get_template('email/forgot_password.html')
            body = mail_template.render( Context( {
                    'username':user.username,
                    'SITE_URL':settings.SITE_URL,
                    'passwordkey':profile.activation_key,
                }))
            #if settings.SEND_EMAILS:
            send_mail('Shaastra2014 password reset request', body,'[email protected]', [user.email,], fail_silently=False)
            dajax.script('$.bootstrapGrowl("An email with a link to reset your password has been sent to your email id: %s", {type:"success",delay:20000} );' % email)
            dajax.script('$.bootstrapGrowl("Please also check your spam", {type:"danger",delay:20000});')
        except ValidationError:
            dajax.script('$.bootstrapGrowl("Your email:%s is invalid", {type:"danger",delay:10000} );' % email)
            return dajax.json()
        except:
            dajax.script('$.bootstrapGrowl("Not a registered email id", {type:"danger",delay:20000} );')
            return dajax.json()
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:32,代码来源:ajax.py

示例2: show_event_tdp

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def show_event_tdp(request,teamevent_id=None):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")    
    if teamevent_id is None:
        dajax.script('$.bootstrapGrowl("Invalid request to view teamevent details", {type:"danger",delay:20000} );')
        return dajax.json()
    try:
        temp = int(teamevent_id)
    except:
        dajax.script('$.bootstrapGrowl("Invalid request to view teamevent details", {type:"danger",delay:20000} );')
        return dajax.json()
    if not request.user.is_authenticated():
        dajax.script('$.bootstrapGrowl("Login to view your event submission details", {type:"danger",delay:20000} );')
        return dajax.json()
    else:
        profile = UserProfile.objects.get(user=request.user)
        try:
            team_event = TeamEvent.objects.get(id=int(teamevent_id))
        except:
            dajax.script('$.bootstrapGrowl("Invalid request", {type:"danger",delay:20000} );')
            return dajax.json()
        now = timezone.now()
        context_dict = {'teamevent':team_event,'profile':profile,'now':now,'TDPFileForm':TDPFileForm(),'settings':settings}
        
        html_stuff = render_to_string('dashboard/event_tdp_submit.html',context_dict,RequestContext(request))
        if html_stuff:
            dajax.assign('#content_dash','innerHTML',html_stuff)
            #dajax.script('$("#event_register").modal("show");')
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:31,代码来源:ajax.py

示例3: edit_profile_password

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [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()
开发者ID:ShaastraWebops,项目名称:ERP14,代码行数:36,代码来源:ajax.py

示例4: edit_profile

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [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()
开发者ID:ShaastraWebops,项目名称:ERP14,代码行数:37,代码来源:ajax.py

示例5: test_dajax

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def test_dajax(request):
    """
        Simple function to rest (D)ajax(ice)
    """
    dajax = Dajax() # To hold the json
    dajax.script('alert(\'hello\');');
    dajax.script( '$("#container_messages").append(\'<div class="span8 offset2"><div class="alert ' + 'alert-success' + ' center"><button type="button" class="close" data-dismiss="alert"><i class="icon-close">&times;</i></button>' + 'This is a test script! No need to listen to me.' + ' </div></div><div class="offset2"></div>\')' )
    return dajax.json()
开发者ID:NSSatIITM,项目名称:nss2k14,代码行数:10,代码来源:ajax.py

示例6: logout

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
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()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:10,代码来源:ajax.py

示例7: select_event_type

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
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()
开发者ID:ShaastraWebops,项目名称:ERP14,代码行数:57,代码来源:ajax.py

示例8: back

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def back(request):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")    
    no_regd = len(request.user.get_profile().get_regd_events())
    reco_events = ParticipantEvent.objects.using(erp_db).filter(registrable_online=True)
#    reco_events = registrable_events(time = timezone.now(),user = request.user)
    context_dict = {'profile':request.user.get_profile(),'no_regd':no_regd,'reco_events':reco_events}
    html_stuff = render_to_string('dashboard/default.html',context_dict,RequestContext(request))
    if html_stuff:
        dajax.assign('#content_dash','innerHTML',html_stuff)
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:13,代码来源:ajax.py

示例9: add_member_form

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def add_member_form(request,teamevent_id = None):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")
    if teamevent_id is None:
        return dajax.json()
    try:
        teamevent = TeamEvent.objects.get(id = teamevent_id)
    except:
        return dajax.json()
    html_stuff = render_to_string('dashboard/add_member.html',{'teamevent':teamevent},RequestContext(request))
    if html_stuff:
        dajax.assign('#content_dash','innerHTML',html_stuff)
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:15,代码来源:ajax.py

示例10: show_tdp_submissions

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def show_tdp_submissions(request):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")
    if not request.user.is_authenticated():
        dajax.script('$.bootstrapGrowl("Login to view your registered events", {type:"danger",delay:20000} );')
        return dajax.json()
    else:
        profile = UserProfile.objects.get(user=request.user)
        team_event_list = profile.get_regd_events()
        tdp_submission_list = []
        for teamevent in team_event_list:
            if teamevent.get_event().has_tdp and teamevent.has_submitted_tdp:
                tdp_submission_list.append(teamevent)
        no_regd = len(tdp_submission_list)
        now = timezone.now()
        title_tdp = 'Your successful TDP Submissions'
        context_dict = {'tdp_submission_list':tdp_submission_list,'profile':profile,'now':now,'no_regd':no_regd,'settings':settings,'title_tdp':title_tdp}
        html_stuff = render_to_string('dashboard/list_tdp_submission.html',context_dict,RequestContext(request))
        if html_stuff:
            dajax.assign('#content_dash','innerHTML',html_stuff)
            #dajax.script('$("#event_register").modal("show");')
    msg_file_upload = request.session.get('file_upload','')
    if msg_file_upload != '':
        del request.session['file_upload']
        print msg_file_upload
        print str(msg_file_upload).startswith('TDP Upload Successful') 
        if str(msg_file_upload).startswith('TDP Upload Successful'):
            dajax.script('$.bootstrapGrowl("%s", {type:"success",delay:20000} );'% msg_file_upload)
        else:
            dajax.script('$.bootstrapGrowl("FileUpload Error: %s", {type:"danger",delay:20000} );'% msg_file_upload)
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:33,代码来源:ajax.py

示例11: change_password_form

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
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()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:17,代码来源:ajax.py

示例12: show_updates

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def show_updates(request):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")
    if not request.user.is_authenticated():
        dajax.script('$.bootstrapGrowl("Login to view your registered events", {type:"danger",delay:20000} );')
        return dajax.json()
    else:
        profile = request.user.get_profile()
        updates_list = list(Update.objects.filter(user = request.user).order_by('tag'))
        #TODO: order by time??: 
        no_updates = len(updates_list)
        now = timezone.now()
        context_dict = {'updates_list':updates_list,'profile':profile,'now':now,'no_updates':no_updates,'settings':settings}
        html_stuff = render_to_string('dashboard/list_updates.html',context_dict,RequestContext(request))
        if html_stuff:
            dajax.assign('#content_dash','innerHTML',html_stuff)
            #dajax.script('$("#event_register").modal("show");')
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:20,代码来源:ajax.py

示例13: delete_task

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def delete_task(request, primkey):
    """
        This function handles deleting any task
        CORES : (ONLY)
            Only they can delete tasks.
        
        Renders in : alert
        Refreshes : right_content
    """
    dajax = Dajax()
    try:
        task = Task.objects.get(pk = primkey)
        subj = task.subject
        task.delete()
        show_alert(dajax, "success", "Task " + subj + " was deleted !") # Shows alert
        dajax.script("modal_hide()") # This refreshes the current tab to update what changes need to be made
    except:
        show_alert(dajax, "error", "That task does not exist !") # Shows alert
        
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:ERP14,代码行数:22,代码来源:ajax.py

示例14: edit_profile

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def edit_profile(request,form = None,first_name = None,last_name = None):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")
    if form is None or first_name is None or last_name is None:
        dajax.script('$.bootstrapGrowl("Invalid edit profile request", {type:"danger",delay:20000} );')
        return dajax.json()
    if first_name == '' or last_name == '':
        dajax.script('$.bootstrapGrowl("Empty first name/last name fields not allowed", {type:"danger",delay:20000} );')
        return dajax.json()
    form = EditProfileForm(deserialize_form(form))
    if not form.is_valid():
        errdict = dict(form.errors)
        for error in form.errors:
#            if str(errdict[error][0])!='This field is required.':
            dajax.script('$.bootstrapGrowl("%s:: %s" , {type:"error",delay:20000} );'% (str(error),str(errdict[error][0])))
        return dajax.json()
    profile = UserProfile.objects.get(user=request.user)
    (profile.branch,profile.mobile_number,profile.college_roll,profile.gender,profile.age)  = (form.cleaned_data['branch'],form.cleaned_data['mobile_number'],form.cleaned_data['college_roll'],form.cleaned_data['gender'],form.cleaned_data['age'])
    profile.user.first_name = first_name
    profile.user.last_name = last_name
    profile.save()
    dajax.script('$.bootstrapGrowl("Your profile has been edited" , {type:"success",delay:10000,align:"center",width:"auto"} );')
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:25,代码来源:ajax.py

示例15: submit_tdp

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import script [as 别名]
def submit_tdp(request,teamevent_id = None,file_tdp=None):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")        
    if teamevent_id is None or file_tdp is None:
        dajax.script('$.bootstrapGrowl("Invalid TDP Upload request", {type:"danger",delay:20000} );')
        return dajax.json()
    team_event =TeamEvent.objects.get(id = teamevent_id)
    if len(request.FILES) == 0:
        dajax.script('$.bootstrapGrowl("Please upload a file first!", {type:"danger",delay:20000} );')
    fileform = TDPFileForm(deserialize_form(file_tdp),request.FILES)

    try:
        event = teamevent.get_event()
        tdp = TDP(tdp=fileform,teamevent = teamevent)
        tdp.save()
    except:
        print
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:20,代码来源:ajax.py


注:本文中的misc.dajax.core.Dajax.script方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。