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


Python Dajax.assign方法代码示例

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


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

示例1: show_blog

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [as 别名]
def show_blog(request, primkey=None):
    """
        Shows the blog entries on the page
        
        Populates : Features
        
        Removes : Showcase, Sponsors
    """
    dajax = Dajax()

    dajax.add_css_class("#showcase", "hide")
    dajax.add_css_class("#sponsors", "hide")

    html_content = ""

    if primkey:
        pass
        show_alert(dajax, "info", "This part has not yet been completed")
    else:
        bloglist = Thread.objects.all()
        # print bloglist
        for i in bloglist:
            i.description = (i.description[:100] + " ....") if len(i.description) > 100 else i.description
        html_content = render_to_string("blog/show.html", {"bloglist": bloglist}, RequestContext(request))

    if html_content:
        dajax.assign("#features", "innerHTML", html_content)

    return dajax.json()
开发者ID:shahidhk,项目名称:robocon_iitm,代码行数:31,代码来源:ajax.py

示例2: choose_event_parti

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

示例3: addroom

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

示例4: edit_profile_password

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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

示例5: show_event_list

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

示例6: add_college

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [as 别名]
def add_college(request,college=None,city=None,state=None):
    dajax = Dajax()
    dajax.script("$(\'#dashboard #loading_dash_dajax\').hide();")    
    #: if user has chosen a college in dropdown, depopulate it OR growl
    if city is None or college is None or state is None or city =='' or college =='' or state =='':
        dajax.script('$.bootstrapGrowl("Please enter relevant details for adding your college", {type:"danger",delay:10000});')
        return dajax.json()
    else:
        try:
            College.objects.get(name__iexact=college)
            dajax.script('$.bootstrapGrowl("Your college is already on our list, please check again", {type:"danger",delay:10000});')
            return dajax.json()
        except:
            coll=None
        dajax.script('$("#add_college").modal(\'hide\');')
        dajax.script('$("#login").show();')
        coll=College(name=college,city=city,state=state)
        try:
            if clean_coll(coll.name) and clean_coll(coll.city):
                coll.save()
            else:
                dajax.script('$.bootstrapGrowl("Please refrain from using profanity", {type:"danger",delay:10000});')
                return dajax.json()
        except:
            coll.save()
        dajax.assign("#add_coll_name",'innerHTML','%s'% college)
        dajax.assign("#add_coll_result",'innerHTML','College:')
        #dajax.script("$('#college')[0]value = '%s'" % college)
        dajax.script('$.bootstrapGrowl("Your college:<strong>%s</strong> was added. Welcome", {type:"success",delay:10000} );'% str(coll.name) )
        # : populate the id_college with the given college details?
        dajax.script("$('#add_coll_message').toggle();")
        dajax.script("$('#form_registration #id_college').toggle();")
        dajax.script("$('#add_coll_form').toggle();")
#    colllist=College.objects.all()
    return dajax.json()
开发者ID:ShaastraWebops,项目名称:shaastra_temporary_mainsite,代码行数:37,代码来源:ajax.py

示例7: show_event_tdp

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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

示例8: show_tdp_submissions

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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

示例9: choose

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

示例10: edit_profile

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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

示例11: roommap

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

示例12: hello_world

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

示例13: logout

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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

示例14: select_event_type

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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

示例15: back

# 需要导入模块: from misc.dajax.core import Dajax [as 别名]
# 或者: from misc.dajax.core.Dajax import assign [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


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