Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
replacing checking of add_experiment permissions with if user is expe…
Browse files Browse the repository at this point in the history
…rimenter or not using template tag

Fix #87
  • Loading branch information
tgpatel committed Mar 18, 2015
1 parent 5f1ce84 commit ac88af3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vcweb/core/templates/experimenter/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "experimenter/base.html" %}
{% load tags %}
{% block title %}Virtual Commons Web Experimenter Dashboard{% endblock %}
{% block page %}
<div class='row' id='page'>
Expand All @@ -14,7 +15,7 @@ <h2>Experimenter Dashboard</h2>
</ul>
<div class='tab-content'>
<div class='tab-pane' id='start'>
{% if not perms.core.add_experiment %}
{% if not request.user|has_group:"Experimenters" %}
<div class='alert alert-warning'>
Demo experimenters cannot start new experiments, try <a href='#running' data-bind='click: activateRunningExperimentsTab'> running an experiment instead</a>.
</div>
Expand Down
6 changes: 6 additions & 0 deletions vcweb/core/templatetags/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from django import template
from django.conf import settings
from django.contrib.auth.models import Group

register = template.Library()

Expand All @@ -30,3 +31,8 @@ def active_re(request, pattern):
return 'active' if re.search(pattern, request.path) else 'inactive'
return 'inactive'


@register.filter(name='has_group')
def has_group(user, group_name):
group = Group.objects.get(name=group_name)
return True if group in user.groups.all() else False

0 comments on commit ac88af3

Please sign in to comment.