Example #1
0
def portal_main2(request):
    message = ""
    #If add tab button was pressed
    if request.method == 'POST' and "addNewTab" in request.POST:
        if request.POST['tab_name'] != '' and request.POST['tab_name'][
                0] != ' ':
            print "yuu"
            event_tab = EventTab()
            event_tab.name = request.POST['tab_name']
            event_tab.content = request.POST['tab_description']
            event_tab.event = Event.objects.get(
                name=request.POST['event_name'])
            event_tab.save()
            message = "The " + request.POST[
                'tab_name'] + " tab has been successfully added to the " + request.POST[
                    'event_name'] + " event"
#If delete tab button was pressed
    if request.method == 'POST' and "delete_tab" in request.POST:
        print "dd"
        event_object = Event.objects.get(name=request.POST['eventName'])
        event_tab = EventTab.objects.get(name=request.POST['event_tab_name'],
                                         event=event_object)
        event_tab.delete()
        message = "The " + request.POST[
            'event_tab_name'] + " tab in the event " + request.POST[
                'eventName'] + " has been successfully deleted"
#If edit tab button was pressed
    if request.method == 'POST' and "EditTab" in request.POST:
        if request.POST['tab_Name'] != '' and request.POST['tab_Name'][
                0] != ' ':
            event_object = Event.objects.get(
                name=request.POST['event_Name_edit_form'])
            event_Tab = EventTab.objects.get(
                name=request.POST['event_tab_Name_edit_form'],
                event=event_object)
            event_Tab.delete()

            event_tab = EventTab()
            event_tab.name = request.POST['tab_Name']
            event_tab.content = request.POST['tab_Description']
            event_tab.event = Event.objects.get(
                name=request.POST['event_Name_edit_form'])
            event_tab.save()

            print "qqqqqqqqu"
            message = "The " + request.POST[
                'tab_Name'] + " tab from the event " + request.POST[
                    'event_Name_edit_form'] + "  has been successfully Edited."

    events = Event.objects.all()
    event_list = []
    for i in events:
        event_list = event_list + [i.name]

    context_dict = {'event_list': event_list, 'message': message}
    return render_to_response('events/events2.html',
                              context_dict,
                              context_instance=global_context(request))
Example #2
0
def add_tab(request,username,add_tab_form):
    add_tab_form=deserialize_form(add_tab_form)
    message=""    
    if add_tab_form['tab_name']!='' and  add_tab_form['tab_name'][0]!=' ':
		event_tab=EventTab()
		event_tab.name=add_tab_form['tab_name']
		event_tab.content=add_tab_form['tab_description']
		event_tab.event=Event.objects.get(name=add_tab_form['event_name'])
		event_tab.save()
		message="The " + add_tab_form['tab_name'] + " tab has been successfully added to the " + add_tab_form['event_name'] + " event"
    return json.dumps({'message': message,'username':username,'event_name':add_tab_form['event_name']})
Example #3
0
def edit_tab(request,username,edit_tab_form):
    edit_tab_form=deserialize_form(edit_tab_form)
    message=""
    if edit_tab_form['tab_Name']!='' and  edit_tab_form['tab_Name'][0]!=' ':
			event_object=Event.objects.get(name=edit_tab_form['event_Name_edit_form'])
			event_Tab=EventTab.objects.get(name=edit_tab_form['event_tab_Name_edit_form'],event=event_object)
			event_Tab.delete()

			event_tab=EventTab()
			event_tab.name=edit_tab_form['tab_Name']
			event_tab.content=edit_tab_form['tab_Description']
			event_tab.event=Event.objects.get(name=edit_tab_form['event_Name_edit_form'])
			event_tab.save()

			message="The " + edit_tab_form['tab_Name'] + " tab from the event " + edit_tab_form['event_Name_edit_form'] + "  has been successfully Edited."

    return json.dumps({'message': message,'username':username,'event_name':event_object.name})
Example #4
0
def portal_main2( request ):
	message=""
#If add tab button was pressed
	if request.method == 'POST' and "addNewTab" in request.POST:
		if request.POST['tab_name']!='' and  request.POST['tab_name'][0]!=' ':
			print "yuu"
	    		event_tab=EventTab()
			event_tab.name=request.POST['tab_name']
			event_tab.content=request.POST['tab_description']
			event_tab.event=Event.objects.get(name=request.POST['event_name'])
			event_tab.save()
			message="The " + request.POST['tab_name'] + " tab has been successfully added to the " + request.POST['event_name'] + " event"
#If delete tab button was pressed	    
	if request.method == 'POST' and "delete_tab" in request.POST:
		print "dd"
		event_object=Event.objects.get(name=request.POST['eventName'])
		event_tab=EventTab.objects.get(name=request.POST['event_tab_name'],event=event_object)
		event_tab.delete()
    		message="The "+ request.POST['event_tab_name']+" tab in the event " + request.POST['eventName']+ " has been successfully deleted"
#If edit tab button was pressed
	if request.method == 'POST' and "EditTab" in request.POST:
		if request.POST['tab_Name']!='' and  request.POST['tab_Name'][0]!=' ':
			event_object=Event.objects.get(name=request.POST['event_Name_edit_form'])
			event_Tab=EventTab.objects.get(name=request.POST['event_tab_Name_edit_form'],event=event_object)
			event_Tab.delete()

			event_tab=EventTab()
			event_tab.name=request.POST['tab_Name']
			event_tab.content=request.POST['tab_Description']
			event_tab.event=Event.objects.get(name=request.POST['event_Name_edit_form'])
			event_tab.save()

			print "qqqqqqqqu"
			message="The " + request.POST['tab_Name'] + " tab from the event " + request.POST['event_Name_edit_form'] + "  has been successfully Edited."


	events=Event.objects.all()
	event_list=[]
	for i in events:
		event_list=event_list+[i.name]
	

	context_dict = {'event_list':event_list,'message':message}
	return render_to_response('events/events2.html', context_dict, context_instance = global_context(request))