Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@render_to(WEBSITE+"/add_whitelist.html")
@login_required
def add_whitelist_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.get(member=user, group=group)
role = get_role_from_group_name(user, group_name)
if membergroup.admin or group.mod_edit_wl_bl and membergroup.moderator:
return {'user': request.user, 'groups': groups, 'group_info': group, 'website' : WEBSITE,
'active_group' : group, 'active_group_role' : role}
else:
return redirect('/404?e=perm')
except Group.DoesNotExist:
return redirect('/404?e=gname&name=%s' % group_name)
except MemberGroup.DoesNotExist:
return redirect('/404?e=member')
@render_to(WEBSITE+"/add_blacklist.html")
@login_required
def add_blacklist_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.get(member=user, group=group)
role = get_role_from_group_name(user, group_name)
if membergroup.admin or group.mod_edit_wl_bl and membergroup.moderator:
return {'user': request.user, 'groups': groups, 'group_info': group, 'website' : WEBSITE,
'active_group' : group, 'active_group_role' : role}
else:
return redirect('/404?e=perm')
except Group.DoesNotExist:
return redirect('/404?e=gname&name=%s' % group_name)
except MemberGroup.DoesNotExist:
return redirect('/404?e=member')
'type': action_type,
'group_name' : group_name,
'group_or_squad' : group_or_squad,
'website' : WEBSITE,
}
# users shouldn't be able to subscribe themselves to a non-public group
g = get_object_or_404(Group, name=group_name)
if not g.public:
return redirect('/404?e=perm')
if request.user.is_authenticated():
user = get_object_or_404(UserProfile, email=request.user.email)
res = engine.main.subscribe_group(group_name, user)
groups = Group.objects.filter(membergroup__member=user).values("name")
if res['status']:
active_group = load_groups(request, groups, user, group_name=group_name)
else:
active_group = {'name':'No Groups Yet'}
if len(groups) > 0:
active_group = load_groups(request, groups, user, group_name=groups[0]['name'])
response.update({
'res' : res,
'user' : request.user,
'groups' : groups,
'active_group' : active_group,
'email' : request.user.email,
});
@render_to(WEBSITE+"/follow_tag.html")
@login_required
def unmute_tag_get(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")
tag_name = request.GET.get('tag')
group_name = request.GET.get('group')
res = engine.main.unmute_tag(tag_name, group_name, user=user)
active_group = load_groups(request, groups, user, group_name=group_name)
return {'res': res, 'type': 'unmut', 'user': request.user, 'groups': groups, 'active_group': active_group}
else:
return redirect("%s?next=/unmute_tag_get?tag=%s&group=%s" % (global_settings.LOGIN_URL, request.GET.get('tag'), request.GET.get('group')))
@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)
@render_to("list_groups.html")
def group_list(request):
try:
user = get_object_or_404(UserProfile, email=request.user.email)
groups = Group.objects.filter(membergroup__member=user).values("name")
except Exception:
user = None
groups = []
pub_groups = engine.main.list_groups(user)
if request.flavour == "mobile":
return HttpResponseRedirect('/pub_group_list')
else:
return {'user': request.user, 'groups': groups, 'pub_groups': pub_groups, 'group_page': True}
@render_to("settings.html")
@login_required
def settings(request):
user = get_object_or_404(UserProfile, email=request.user.email)
groups = Group.objects.filter(membergroup__member=user).values("name")
groups_links = get_groups_links_from_roles(user, groups)
#active_group = load_groups(request, groups, user)
return {'user': request.user, "groups": groups, 'groups_links': groups_links, 'website' : WEBSITE, 'group_page' : True}
group_name = request.GET.get('group_name')
if not request.user.is_authenticated():
return redirect(global_settings.LOGIN_URL + '?next=/unsubscribe_get?group_name=' + group_name)
if WEBSITE == 'murmur':
action_type = 'unsubscribed from'
elif WEBSITE == 'squadbox':
action_type = 'left'
user = get_object_or_404(UserProfile, email=request.user.email)
res = engine.main.unsubscribe_group(group_name, user)
g = get_object_or_404(Group, name=group_name)
groups = Group.objects.filter(membergroup__member=user).values("name")
active_group = {'name':'No Groups Yet'}
if len(groups) > 0:
active_group = load_groups(request, groups, user, group_name=groups[0]['name'])
return {
'res':res,
'type': action_type,
'user': request.user,
'group_name' : group_name,
'groups' : groups,
'active_group': active_group,
'group_or_squad' : group_or_squad,
'public' : g.public,
'website' : WEBSITE,
}
forward_address = group_name + '@' + BASE_URL
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})
@render_to("follow_tag.html")
@login_required
def unmute_tag_get(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")
tag_name = request.GET.get('tag')
group_name = request.GET.get('group')
res = engine.main.unmute_tag(tag_name, group_name, user=user)
active_group = load_groups(request, groups, user, group_name=group_name)
return {'res': res, 'type': 'unmut', 'user': request.user, 'groups': groups, 'active_group': active_group}
else:
return redirect("%s?next=/unmute_tag_get?tag=%s&group=%s" % (global_settings.LOGIN_URL, request.GET.get('tag'), request.GET.get('group')))