Exemplo n.º 1
0
def SearchActivity(request):
    limit = 6
    isOrganizer = False
    isAdmin = False
    if request.user.is_anonymous() == False:
        isOrganizer = is_organizer(request.user)
        isAdmin = is_admin(request.user)
    q = request.GET['q']
    activities = Activity.objects.filter(publishdate__isnull=False).filter(
        atstatus=0).filter(
            Q(atname__icontains=q)
            | Q(atorganizer__username__icontains=q)).order_by('-publishdate')
    paginator = Paginator(activities, limit)
    page = request.GET.get('page')
    try:
        activities = paginator.page(page)
    except PageNotAnInteger:
        activities = paginator.page(1)
    except EmptyPage:
        activities = paginator.page(paginator.num_pages)
    return render_to_response('templates/philosopher/homepage.html', {
        "activities": activities,
        "isOrganizer": isOrganizer,
        "isAdmin": isAdmin,
        'queryValue': q
    },
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def ActivityDetail(request, activityid):
	isOrganizer = False
	isAdmin = False
	isStudent = False
	has_right = False
	activity = get_object_or_404(Activity, pk = activityid)
	#newTen = Activity.objects.filter(publishdate__isnull = False).filter(atstatus=0).order_by('-publishdate')[:9]
	if request.user.is_anonymous() == False: 
		isOrganizer = is_organizer(request.user)
		isAdmin = is_admin(request.user)
		isStudent = is_student(request.user)
	if ( isOrganizer and activity.atorganizer.id == request.user.id ) or isAdmin:
		has_right = True
	isApplied = False
	myApplicationId = -1
	if isStudent:
		if request.user.application_set.filter(activityid = activityid).exists():
			isApplied = True
			myApplication = request.user.application_set.get(activityid = activityid)
			myApplicationId = myApplication.id
	passApplications = activity.application_set.filter(apstatus = 0)
	waitApplications = activity.application_set.filter(apstatus = 2)
	rejectApplications = activity.application_set.filter(apstatus= 1)
	finishApplications = activity.application_set.filter(apstatus = 3)
	failApplications = activity.application_set.filter(apstatus = 4)
	return render_to_response('templates/philosopher/activitydetail.html',
		{"activity": activity, "isAdmin":isAdmin, "isStudent":isStudent, "isApplied":isApplied,
		 "has_right": has_right, 'myApplicationId':myApplicationId, "passApplications":passApplications,
		 "waitApplications":waitApplications, "rejectApplications":rejectApplications, "finishApplications":finishApplications,
		 "failApplications":failApplications },
		context_instance = RequestContext(request))
Exemplo n.º 3
0
def ActivityDetail(request, activityid):
	isOrganizer = False
	isAdmin = False
	isStudent = False
	has_right = False
	activity = get_object_or_404(Activity, pk = activityid)
	#newTen = Activity.objects.filter(publishdate__isnull = False).filter(atstatus=0).order_by('-publishdate')[:9]
	if request.user.is_anonymous() == False: 
		isOrganizer = is_organizer(request.user)
		isAdmin = is_admin(request.user)
		isStudent = is_student(request.user)
	if ( isOrganizer and activity.atorganizer.id == request.user.id ) or isAdmin:
		has_right = True
	isApplied = False
	myApplicationId = -1
	if isStudent:
		if request.user.application_set.filter(activityid = activityid).exists():
			isApplied = True
			myApplication = request.user.application_set.get(activityid = activityid)
			myApplicationId = myApplication.id
	passApplications = activity.application_set.filter(apstatus = 0)
	waitApplications = activity.application_set.filter(apstatus = 2)
	rejectApplications = activity.application_set.filter(apstatus= 1)
	finishApplications = activity.application_set.filter(apstatus = 3)
	failApplications = activity.application_set.filter(apstatus = 4)
	return render_to_response('templates/philosopher/activitydetail.html',
		{"activity": activity, "isAdmin":isAdmin, "isStudent":isStudent, "isApplied":isApplied,
		 "has_right": has_right, 'myApplicationId':myApplicationId, "passApplications":passApplications,
		 "waitApplications":waitApplications, "rejectApplications":rejectApplications, "finishApplications":finishApplications,
		 "failApplications":failApplications },
		context_instance = RequestContext(request))
Exemplo n.º 4
0
def Homepage(request):
	limit = 6
	isOrganizer = False
	isAdmin = False
	if request.user.is_anonymous() == False: 
		isOrganizer = is_organizer(request.user)
		isAdmin = is_admin(request.user)
	activities = Activity.objects.filter(publishdate__isnull = False).filter(atstatus=0).order_by('-publishdate')
	paginator = Paginator(activities, limit)
	page = request.GET.get('page')
	try:
		activities = paginator.page(page)
	except PageNotAnInteger:
		activities = paginator.page(1)
	except EmptyPage:
		activities = paginator.page(paginator.num_pages)
	return render_to_response('templates/philosopher/homepage.html', 
		{"activities": activities, "isOrganizer":isOrganizer, "isAdmin":isAdmin}, 
		context_instance = RequestContext(request) )