コード例 #1
0
ファイル: ajax.py プロジェクト: ShaastraWebops/ERP14
def update_event(request,form):
    dajax = Dajax()
    form = UpdateForm(deserialize_form(form))
    event_object = request.user.get_profile().event
    all_updates = Update.objects.filter(event=event_object)
    major_count = 0
    update_count = 0
    if form.is_valid():
        for u in all_updates:
            if u.category=='Updates' and u.expired is False:
                update_count = update_count + 1
                print update_count
            elif u.category=='Major Update' and u.expired is False:
                major_count = major_count + 1
                print major_count
            elif update_count>4 and u.category=='Updates':
                dajax.alert("This event already has 4 Updates.\
                    Please mark one update as Expired before adding a new update")
            elif major_count>1 and u.category=='Major Update':
                dajax.alert("This event already has one Major Update.\
                    Please mark the Major Update as Expired before adding another one")
    #Write to json here

    else :
        template = loader.get_template('events/home.html')
        t = template.render(RequestContext(request,locals()))
    return dajax.json()
コード例 #2
0
def hello(request, form=None):
    """
        Test dajax
    """
    dajax = Dajax()
    
    dajax.alert("got from dajax");
    
    return dajax.json()
コード例 #3
0
ファイル: ajax.py プロジェクト: gowtham-v/Shaastra_user
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})