Ejemplo n.º 1
0
def index(request):
	if request.method == method.GET:
		qset = Badword.objects.all()
	elif request.method == method.POST:
		per_page = request.POST.get('per_page')
		if per_page != None:
			Profile.objects.filter(user=request.user).update(per_page_badwords=per_page)
			return HttpResponse()
		form = BadwordSearchForm(request.POST)
		if not form.is_valid():
			return HttpResponseBadRequest(_('Invalid search criteria'))
		values = form.cleaned_data
		#print values
		qset = Badword.objects.all()
		if values['badword']:
			qset = qset.filter(badword__icontains=values['badword'])
	profile = request.user.get_profile()
	order_by = request.GET.get('sort', 'badword')
	result = CustomPaginator(qset) \
		.instantiate(BadwordTable, qset, order_by=order_by) \
		.with_request(request)
	page = result.page(None, profile.per_page_badwords)
	context_instance = RequestContext(request)
	template_name = 'badwords/list.html'
	extra_context = {
		'menu': 'badwords',
		'table': result.instance,
		'page': page,
		'search_form': BadwordSearchForm()
	}
	return render_to_response(template_name, extra_context, context_instance)
Ejemplo n.º 2
0
def index(request):
	if request.method == method.GET:
		qset = UserGroup.objects.all()
	elif request.method == method.POST:
		per_page = request.POST.get('per_page')
		if per_page != None:
			Profile.objects.filter(user=request.user).update(per_page_usergroups=per_page)
			return HttpResponse()
		form = GroupSearchForm(request.POST)
		if not form.is_valid():
			return HttpResponseBadRequest(_('Invalid search criteria'))
		values = form.cleaned_data
		#print values
		qset = UserGroup.objects.all()
		if values['groupname']:
			qset = qset.filter(groupname__icontains=values['groupname'])
		if values['description']:
			qset = qset.filter(description__icontains=values['description'])
	profile = request.user.get_profile()
	order_by = request.GET.get('sort', 'groupname')
	qset2 = qset.select_related('user').annotate(user_count=Count('users'))
	result = CustomPaginator(qset) \
		.instantiate(GroupTable, qset2, order_by=order_by) \
		.with_request(request) \
		.with_count(qset.count())
	page = result.page(None, profile.per_page_usergroups)
	context_instance = RequestContext(request)
	template_name = 'groups/list.html'
	extra_context = {
		'menu': 'groups',
		'table': result.instance,
		'page': page,
		'search_form': GroupSearchForm()
	}
	return render_to_response(template_name, extra_context, context_instance)
Ejemplo n.º 3
0
def index(request):
	if request.method == method.GET:
		qset = User.objects.all()
	elif request.method == method.POST:
		form = ProfileSearchForm(request.POST)
		if not form.is_valid():
			return HttpResponseBadRequest(_('Invalid search criteria'))
		values = form.cleaned_data
		#print values
		qset = User.objects.all()
		if values['username']:
			qset = qset.filter(username__icontains=values['username'])
		if values['email']:
			qset = qset.filter(email__icontains=values['email'])
		if values['group']:
			qset = qset.filter(groups=values['group'])
	order_by = request.GET.get('sort', 'username')
	result = CustomPaginator(qset) \
		.using_class(ProfileTable, qset, order_by=order_by) \
		.with_request(request)
	page = result.page(None, 5)
	context_instance = RequestContext(request)
	template_name = 'profiles/list.html'
	extra_context = {
		'menu': 'profiles',
		'table': result.table,
		'page': page,
		'search_form': ProfileSearchForm()
	}
	return render_to_response(template_name, extra_context, context_instance)
Ejemplo n.º 4
0
def index(request):
	if request.method == method.GET:
		qset = Message.objects.all()
	elif request.method == method.POST:
		per_page = request.POST.get('per_page')
		if per_page != None:
			Profile.objects.filter(user=request.user).update(per_page_conversations=per_page)
			return HttpResponse()
		form = MessageSearchForm(request.POST)
		if not form.is_valid():
			return HttpResponseBadRequest(_('Invalid search criteria'))
		values = form.cleaned_data
		try:
			if values['to_date']:
				values['to_date'] = adjust_date(values['to_date'], True)
		except ValueError:
			return HttpResponseBadRequest(_('Invalid date'))
		qset = Message.objects.all()
		if values['from_date']:
			qset = qset.filter(timestamp__gte=values['from_date'])
		if values['to_date']:
			qset = qset.filter(timestamp__lte=values['to_date'])
		if values['message']:
			qset = qset.filter(content__icontains=values['message'])
		if values['localim']:
			qset = qset.filter(localim__icontains=values['localim'])
#			qset = qset.filter(
#				(Q(inbound = False) & Q(localim__icontains = values['localim'])) |
#				(Q(inbound = True) & Q(remoteim__icontains = values['localim']))
#			)
		if values['remoteim']:
			qset = qset.filter(remoteim__icontains=values['remoteim'])
#			qset = qset.filter(
#				(Q(inbound = True) & Q(localim__icontains = values['remoteim'])) |
#				(Q(inbound = False) & Q(remoteim__icontains = values['remoteim']))
#			)
		if values['filtered']:
			qset = qset.filter(filtered=values['filtered'])
	profile = request.user.get_profile()
	order_by = request.GET.get('sort', '-timestamp')
	result = CustomPaginator(qset) \
		.instantiate(MessageTable, qset, order_by=order_by) \
		.with_request(request) \
		.group_by(True, 'conversation_id')
	page = result.page(None, profile.per_page_conversations)
	context_instance = RequestContext(request)
	template_name = 'conversations/list.html'
	extra_context = {
		'menu': 'conversations',
		'table': result.instance,
		'page': page,
		'search_form': MessageSearchForm()
	}
	return render_to_response(template_name, extra_context, context_instance)
Ejemplo n.º 5
0
def index(request, user_id):
	user_id = long(user_id)
	from_user = get_object_or_404(User, pk=user_id)
	if request.method == method.GET:
		qset = Buddy.objects.filter(user=user_id)
	elif request.method == method.POST:
		per_page = request.POST.get('per_page')
		if per_page != None:
			Profile.objects.filter(user=request.user).update(per_page_buddies=per_page)
			return HttpResponse()
		form = BuddySearchForm(request.POST)
		if not form.is_valid():
			return HttpResponseBadRequest(_('Invalid search criteria'))
		values = form.cleaned_data
		#print values
		qset = Buddy.objects.filter(user=user_id)
		if values['username']:
			qset = qset.filter(username__icontains=values['username'])
		if values['displayname']:
			qset = qset.filter(displayname__icontains=values['displayname'])
		if values['status']:
			qset = qset.filter(status=values['status'])
	profile = request.user.get_profile()
	order_by = request.GET.get('sort', 'username')
	result = CustomPaginator(qset) \
		.instantiate(BuddyTable, qset, order_by=order_by) \
		.with_request(request)
	page = result.page(None, profile.per_page_buddies)
	context_instance = RequestContext(request)
	template_name = 'buddies/list.html'
	extra_context = {
		'menu': 'users',
		'table': result.instance,
		'page': page,
		'from_user': from_user,
		'search_form': BuddySearchForm()
	}
	return render_to_response(template_name, extra_context, context_instance)