How to use the schema.models.Group.objects.get 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
subj_tag = ''
			for tag in res['tags']:
				subj_tag += '[%s]' % tag['name']
			
			subject = 'Re: [%s]%s %s' %(group_name, subj_tag, orig_subject)

			mail = setup_post(user.email,
					subject,	
					group_name)
		
			mail['References'] = msg_id		
			mail['message-id'] = res['msg_id']
			
			mail["In-Reply-To"] = msg_id
			
			g = Group.objects.get(name=group_name)
			t = Thread.objects.get(id=res['thread_id'])
			
			logging.debug('TO LIST: ' + str(to_send))
			
			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:
github haystack / murmur / gmail_setup / views.py View on Github external
if WEBSITE == "squadbox":
            filter_hash = engine.main.get_or_generate_filter_hash(user, group_name, push=False)['hash']
            try:
                api.create_gmail_filter(service_mail, emails_to_add, forward_address, filter_hash)
            except Exception, e:
                logging.error("Exception creating gmail filter - probably hit request limit")
                logging.debug(e)

        return HttpResponseRedirect('/gmail_setup/done?group=' + group_name)
    else:
        # generate form objects for first load here
        group_name = request.GET.get('group')

        groups = Group.objects.filter(membergroup__member=user).values("name")
        groups_links = get_groups_links_from_roles(user, groups)
        active_group = Group.objects.get(name=group_name)
        # TODO: combine multiple email addresses for same contact in contacts view
        return render(request, 'gmail_setup_import.html', {'website': WEBSITE, 'user': user, 
            'contacts_names_emails': contacts_names_emails, 'sorted_gmail_list': sorted_gmail_list, 
            'group_name': group_name, 'max_frequency': max_frequency, 'min_frequency': min_frequency, 
            'frequency_list': frequency_list, 'freq_contacted' : freq_contacted, 'groups': groups, 
            'active_group' : active_group, 'active_group_role' : 'admin', 'groups_links' : groups_links})
github haystack / murmur / browser / views.py View on Github external
@render_to("mobile_list_posts.html")
def post_list(request):
	if request.user.is_authenticated():
		user = get_object_or_404(UserProfile, email=request.user.email)
		groups = Group.objects.filter(membergroup__member=user).values("name")
		
		active_group = load_groups(request, groups, user)
		is_member = False
		group_name = request.GET.get('group_name')
		if active_group['active']:
			group = Group.objects.get(name=active_group['name'])
			is_member = MemberGroup.objects.filter(member=user, group=group).exists()
			group_name = active_group['name']
			
		if group.public or is_member:
			if is_member:
				request.session['active_group'] = group_name
			res = engine.main.list_posts(group_name=group_name, user=user, format_datetime=False, return_replies=True)
			res['threads'] = paginator(request.GET.get('page'), res['threads'])
			return {'user': request.user, 'groups': groups, 'posts': res, 'active_group': active_group}
		else:
			return redirect('/404?e=member')
	else:
		user = None
		groups = []
		active_group = {'name': request.GET.get('group_name')}
		if active_group['name']:
github haystack / murmur / browser / views.py View on Github external
if request.POST['subject'][0:4].lower() == "re: ":
			orig_subject = re.sub("\[.*?\]", "", request.POST['subject'][4:]).strip()
		else:
			orig_subject = re.sub("\[.*?\]", "", request.POST['subject']).strip()
		
		msg_text = request.POST['msg_text']
		
		#msg_id = request.POST['msg_id'].encode('ascii', 'ignore')
		msg_id = base64.b64encode(user.email + str(datetime.now())).lower() + '@' + BASE_URL
		
		original_group = None
		original_group_object = None
		if 'original_group' in request.POST:
			original_group = request.POST['original_group'] + '@' + HOST
			group = Group.objects.get(name=group_name)
			original_group_object = ForwardingList.objects.get(email=original_group, group=group)

		res = engine.main.insert_reply(group_name, 'Re: ' + orig_subject, msg_text, user, user.email, msg_id, True, forwarding_list=original_group_object, thread_id=thread_id)

		if(res['status']):
			to_send =  res['recipients']
			post_addr = '%s <%s>' %(group_name, group_name + '@' + HOST)
			
					
			subj_tag = ''
			for tag in res['tags']:
				subj_tag += '[%s]' % tag['name']
			
			subject = 'Re: [%s]%s %s' %(group_name, subj_tag, orig_subject)

			mail = setup_post(user.email,
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
@render_to(WEBSITE+"/create_post.html")
@login_required
def my_group_create_post_view(request, group_name):
	if request.user.is_authenticated():
		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)
			member = MemberGroup.objects.get(member=user, group=group)
			return {'user': request.user, 'groups': groups, 'group_info': group, 'group_page': True}
		except Group.DoesNotExist:
			return redirect('/404?e=gname&name=%s' % group_name)
		except MemberGroup.DoesNotExist:
			return redirect('/404?e=member')
	else:
		return HttpResponseRedirect(global_settings.LOGIN_URL)
github haystack / murmur / gmail_setup / views.py View on Github external
forward_address = group_name + '@' + BASE_URL

    services = build_services(user)

    is_authorized = False 
    # Used for Squadbox only:
    gmail_forwarding_verified = False

    if services is not None:
        is_authorized = True
        service_mail = services['mail']
        gmail_forwarding_verified = api.check_forwarding_address(service_mail, forward_address)

    groups = Group.objects.filter(membergroup__member=user).values("name")
    groups_links = get_groups_links_from_roles(user, groups)
    active_group = Group.objects.get(name=group_name)

    return {'website': WEBSITE, 'user': user, 'is_authorized': is_authorized, 'gmail_forwarding_verified': gmail_forwarding_verified, 
        'is_done': is_done, 'group_name': group_name, 'forward_address': forward_address, 'groups' : groups, 'active_group' : active_group,
        'groups_links' : groups_links, 'active_group_role' : 'admin'}
github haystack / murmur / browser / views.py View on Github external
orig_subject = request.POST['subject']
		
		if request.POST['subject'][0:4].lower() == "re: ":
			orig_subject = re.sub("\[.*?\]", "", request.POST['subject'][4:]).strip()
		else:
			orig_subject = re.sub("\[.*?\]", "", request.POST['subject']).strip()
		
		msg_text = request.POST['msg_text']
		
		msg_id = request.POST['msg_id'].encode('ascii', 'ignore')
		
		original_group = None
		original_group_object = None
		if 'original_group' in request.POST:
			original_group = request.POST['original_group'] + '@' + HOST
			group = Group.objects.get(name=group_name)
			original_group_object = ForwardingList.objects.get(email=original_group, group=group)

		res = engine.main.insert_reply(group_name, 'Re: ' + orig_subject, msg_text, user, user.email, forwarding_list=original_group_object, thread_id=thread_id)
		
		if(res['status']):
			
			to_send =  res['recipients']
			post_addr = '%s <%s>' %(group_name, group_name + '@' + HOST)
			
					
			subj_tag = ''
			for tag in res['tags']:
				subj_tag += '[%s]' % tag['name']
			
			subject = 'Re: [%s]%s %s' %(group_name, subj_tag, orig_subject)
github haystack / murmur / browser / views.py View on Github external
group_name = active_group['name']
			
		if group.public or is_member:
			if is_member:
				request.session['active_group'] = group_name
			res = engine.main.list_posts(group_name=group_name, user=user, format_datetime=False, return_replies=True)
			res['threads'] = paginator(request.GET.get('page'), res['threads'])
			return {'user': request.user, 'groups': groups, 'posts': res, 'active_group': active_group}
		else:
			return redirect('/404?e=member')
	else:
		user = None
		groups = []
		active_group = {'name': request.GET.get('group_name')}
		if active_group['name']:
			group = Group.objects.get(name=active_group['name'])
			if not group.public:
				return redirect('/404?e=member')
			else:
				res = engine.main.list_posts(group_name=request.GET.get('group_name'), format_datetime=False, return_replies=False)
				return {'user': request.user, 'groups': groups, 'posts': res, 'active_group': active_group}
		else:
			return HttpResponseRedirect(global_settings.LOGIN_URL)
github haystack / murmur / browser / views.py View on Github external
@render_to(WEBSITE+"/add_members.html")
@login_required
def add_members_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, 'website': WEBSITE,
			'active_group' : group, 'active_group_role' : 'admin'}
		else:
			return redirect('/404?e=admin')
	except Group.DoesNotExist:
		return redirect('/404?e=gname&name=%s' % group_name)