How to use the schema.models.MemberGroup.objects.filter function in schema

To help you get started, we’ve selected a few schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github haystack / murmur / browser / views.py View on Github external
@render_to("add_list.html")
@login_required
def add_list_view(request, group_name):
	user = get_object_or_404(UserProfile, email=request.user.email)
	groups = Group.objects.filter(membergroup__member=user).values("name")
	try:
		group = Group.objects.get(name=group_name)
		membergroup = MemberGroup.objects.filter(member=user, group=group)
		if membergroup.count() == 1 and membergroup[0].admin:
			return {'user': request.user, 'groups': groups, 'group_info': group, 'group_page': True}
		else:
			return redirect('/404?e=admin')
	except Group.DoesNotExist:
		return redirect('/404?e=gname&name=%s' % group_name)
github haystack / murmur / browser / views.py View on Github external
@render_to(WEBSITE+"/edit_create_group.html")
@login_required
def edit_group_info_view(request, group_name):
	user = get_object_or_404(UserProfile, email=request.user.email)  
	groups = Group.objects.filter(membergroup__member=user).values("name")  #defines the user and the groups this user is in.
	try:
		group = Group.objects.get(name=group_name)
		membergroup = MemberGroup.objects.filter(member=user, group=group)
		groups_links = get_groups_links_from_roles(user, groups)
		if membergroup[0].admin:
			return {'user': request.user, 'groups': groups, 'group_info': group, 'group_page': True, 
					'website' : WEBSITE, 'group_or_squad' : group_or_squad, 'active_group' : group, 
					'active_group_role' : 'admin', 'groups_links' : groups_links, 'edit_page' : True}
		else:
			return redirect('/404?e=admin')
	except Group.DoesNotExist:
		return redirect('/404?e=gname&name=%s' % group_name)
github haystack / murmur / browser / views.py View on Github external
@render_to(WEBSITE+"/add_list.html")
@login_required
def add_list_view(request, group_name):
	user = get_object_or_404(UserProfile, email=request.user.email)
	groups = Group.objects.filter(membergroup__member=user).values("name")
	try:
		group = Group.objects.get(name=group_name)
		membergroup = MemberGroup.objects.filter(member=user, group=group)
		if membergroup.count() == 1 and membergroup[0].admin:
			return {'user': request.user, 'groups': groups, 'group_info': group, 'group_page': True}
		else:
			return redirect('/404?e=admin')
	except Group.DoesNotExist:
		return redirect('/404?e=gname&name=%s' % group_name)
github haystack / murmur / browser / views.py View on Github external
try:
				group_name = Thread.objects.get(id=thread_id).group.name
			except Thread.DoesNotExist:
				pass
			active_group = load_groups(request, groups, user, group_name=group_name)
		else:
			active_group = load_groups(request, groups, user)
			
		tag_info = None
		member_info = None
		is_member = False

		if active_group['active']:
			group = Group.objects.get(name=active_group['name'])
			active_group['description'] = group.description
			member = MemberGroup.objects.filter(member=user, group=group)
			if member.count() > 0:
				is_member = True
				member_info = member[0]
	
			tag_info = Tag.objects.filter(group=group).annotate(num_p=Count('tagthread')).order_by('-num_p')
			for tag in tag_info:
				tag.muted = tag.mutetag_set.filter(user=user, group=group).exists()
				tag.followed = tag.followtag_set.filter(user=user, group=group).exists()
			
		page_info = {"user": user, 
					"active_group": active_group, 
					"groups": groups, 
					"tag_info": tag_info, 
					"member_info": member_info,
					}
github haystack / murmur / browser / views.py View on Github external
post_addr = '%s <%s>' %(group_name, group_name + '@' + HOST)
		
		mail = setup_post(user.email,
					subject,	
					group_name)
		
		mail['message-id'] = msg_id
		
		g = Group.objects.get(name=group_name)
		t = Thread.objects.get(id=res['thread_id'])
		
		if len(to_send) > 0:
			logging.debug('Insert post to : ' + str(to_send))
			recips = UserProfile.objects.filter(email__in=to_send)
			membergroups = MemberGroup.objects.filter(group=g, member__in=recips)
			
			followings = Following.objects.filter(thread=t, user__in=recips)
			mutings = Mute.objects.filter(thread=t, user__in=recips)
			
			tag_followings = FollowTag.objects.filter(group=g, tag__in=res['tag_objs'], user__in=recips)
			tag_mutings = MuteTag.objects.filter(group=g, tag__in=res['tag_objs'], user__in=recips)
			
			
			for recip in recips:
				membergroup = membergroups.filter(member=recip)[0]
				following = followings.filter(user=recip).exists()
				muting = mutings.filter(user=recip).exists()
				tag_following = tag_followings.filter(user=recip)
				tag_muting = tag_mutings.filter(user=recip)

				original_group = None
github haystack / murmur / browser / views.py View on Github external
@render_to(WEBSITE+"/add_donotsend.html")
@login_required
def add_dissimulate_view(request, group_name):
	user = get_object_or_404(UserProfile, email=request.user.email)
	groups = Group.objects.filter(membergroup__member=user).values("name")

	try:
		group = Group.objects.get(name=group_name)
		membergroup = MemberGroup.objects.filter(member=user, group=group)
		return {'user': request.user, 'groups': groups, 'group_info': group, 'group_page': True, 'website': WEBSITE,
			'active_group' : group, 'active_group_role' : 'admin'}

	except Group.DoesNotExist:
		return redirect('/404?e=gname&name=%s' % group_name)
github haystack / murmur / browser / views.py View on Github external
@login_required
def serve_attachment(request, hash_filename):

	if request.user.is_authenticated():
		try:
			user = get_object_or_404(UserProfile, email=request.user.email)
			attachment = Attachment.objects.get(hash_filename=hash_filename)
			group = Post.objects.get(msg_id=attachment.msg_id).group

			if MemberGroup.objects.filter(member=user, group=group).exists():
				s3 = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, is_secure=True)
				filepath = '%s/attachments/%s/%s' % (WEBSITE, hash_filename, attachment.true_filename)
				temporary_auth_url = s3.generate_url(60, 'GET', bucket=AWS_STORAGE_BUCKET_NAME, key=filepath)
				return HttpResponseRedirect(temporary_auth_url)
			else:
				return HttpResponse('/404?e=member')

		except Attachment.DoesNotExist:
			logging.debug("No attachment with hash filename %s" % hash_filename)
			return HttpResponseRedirect('/404')

		except Post.DoesNotExist:
			logging.debug("No post with msg id %s" % attachment.msg_id)
			return HttpResponseRedirect('/404')

		except Exception, e:
github haystack / murmur / browser / views.py View on Github external
@render_to("edit_group_info.html")
@login_required
def edit_group_info_view(request, group_name):
	user = get_object_or_404(UserProfile, email=request.user.email)  
	groups = Group.objects.filter(membergroup__member=user).values("name")  #defines the user and the groups this user is in.
	try:
		group = Group.objects.get(name=group_name)
		membergroup = MemberGroup.objects.filter(member=user, group=group)
		if membergroup[0].admin:
			return {'user': request.user, 'groups': groups, 'group_info': group, 'group_page': True}
		else:
			return redirect('/404?e=admin')
	except Group.DoesNotExist:
		return redirect('/404?e=gname&name=%s' % group_name)
github haystack / murmur / browser / views.py View on Github external
post_addr = '%s <%s>' %(group_name, group_name + '@' + HOST)
		
		mail = setup_post(user.email,
					subject,	
					group_name)
		
		mail['message-id'] = msg_id
		
		g = Group.objects.get(name=group_name)
		t = Thread.objects.get(id=res['thread_id'])
		
		if len(to_send) > 0:
			
			recips = UserProfile.objects.filter(email__in=to_send)
			membergroups = MemberGroup.objects.filter(group=g, member__in=recips)
			
			followings = Following.objects.filter(thread=t, user__in=recips)
			mutings = Mute.objects.filter(thread=t, user__in=recips)
			
			tag_followings = FollowTag.objects.filter(group=g, tag__in=res['tag_objs'], user__in=recips)
			tag_mutings = MuteTag.objects.filter(group=g, tag__in=res['tag_objs'], user__in=recips)
			
			
			for recip in recips:
				membergroup = membergroups.filter(member=recip)[0]
				following = followings.filter(user=recip).exists()
				muting = mutings.filter(user=recip).exists()
				tag_following = tag_followings.filter(user=recip)
				tag_muting = tag_mutings.filter(user=recip)

				original_group = None
github haystack / murmur / browser / views.py View on Github external
@render_to(WEBSITE+"/rejected_thread.html")
def rejected_thread(request):
	
	post_id = request.GET.get('post_id')
	thread_id = request.GET.get('tid')
	try:
		thread = Thread.objects.get(id=int(thread_id))
	except Thread.DoesNotExist:
		return redirect('/404?e=thread')
	
	group = thread.group
	
	if request.user.is_authenticated():
		user = get_object_or_404(UserProfile, email=request.user.email)
		mg = MemberGroup.objects.filter(member=user, group=group)
		if mg.exists() and (mg[0].admin or mg[0].moderator):
			res = engine.main.load_thread(thread, user=request.user, member=mg[0])
			groups = Group.objects.filter(membergroup__member=user).values("name")
			if WEBSITE == 'murmur':
				thread_to = '%s@%s' % (group.name, HOST) 
			elif WEBSITE == 'squadbox':
				thread_to = user.email

			groups = Group.objects.filter(membergroup__member=user).values("name")
			groups_links = get_groups_links_from_roles(user, groups)
			active_group = group
			active_group_role = get_role_from_group_name(user, group.name)

			return {'user': request.user, 'groups': groups, 'group_name' : group.name, 'thread': res, 'post_id': post_id, 
			'thread_to' : thread_to, 'website' : WEBSITE, 'groups_links' : groups_links, group_page: True,
			'active_group' : active_group, 'active_group_role' : active_group_role}