<commit_before>'''
Module containing views for managing access control groups.

@author: <NAME>
'''
from collections import OrderedDict

from django.contrib.auth.decorators import login_required
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse
from django.http import HttpRequest, HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from django.template.loader import render_to_string
from sqlalchemy.orm.exc import NoResultFound
from django.template import TemplateDoesNotExist

from cog.forms import PermissionForm
from cog.models import User, UserProfile, getSiteAdministrators
from cog.models import getPeerSites
from cog.notification import notify
from cog.plugins.esgf.objects import ROLE_USER, ROLE_PUBLISHER, ROLE_SUPERUSER, ROLE_ADMIN
from cog.services.registration import esgfRegistrationServiceImpl as registrationService
from cog.utils import getJson
from constants import PERMISSION_DENIED_MESSAGE, SAVED


@login_required
def ac_subscribe(request, group_name):
    '''
    View to request an access control permission.
    Currently, it can only be used to request ROLE_USER.
    '''
            
    title = '%s Data Access Request' % group_name
    template = 'cog/access_control/subscribe.html'

    # display submission form
    if request.method=='GET':
        
        status = registrationService.status(request.user.profile.openid(), group_name, ROLE_USER)
        
        licenseTxt = None
        licenseHtml = None
        try:
            licenseFile = 'cog/access_control/licenses/%s.txt' % group_name
            licenseTxt = render_to_string(licenseFile)
        except TemplateDoesNotExist:
            try:
                licenseFile = 'cog/access_control/licenses/%s.html' % group_name
                licenseHtml = render_to_string(licenseFile)
            except TemplateDoesNotExist:
                pass
        <commit_msg>Preventin subscription to 'wheel' group.<commit_after>'''
Module containing views for managing access control groups.

@author: <NAME>
'''
from collections import OrderedDict

from django.contrib.auth.decorators import login_required
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse
from django.http import HttpRequest, HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from django.template.loader import render_to_string
from sqlalchemy.orm.exc import NoResultFound
from django.template import TemplateDoesNotExist

from cog.forms import PermissionForm
from cog.models import User, UserProfile, getSiteAdministrators
from cog.models import getPeerSites
from cog.notification import notify
from cog.plugins.esgf.objects import ROLE_USER, ROLE_PUBLISHER, ROLE_SUPERUSER, ROLE_ADMIN
from cog.services.registration import esgfRegistrationServiceImpl as registrationService
from cog.utils import getJson
from constants import PERMISSION_DENIED_MESSAGE, SAVED


@login_required
def ac_subscribe(request, group_name):
    '''
    View to request an access control permission.
    Currently, it can only be used to request ROLE_USER.
    '''
            
    title = '%s Data Access Request' % group_name
    template = 'cog/access_control/subscribe.html'
    
    # prevent requests to 'wheel' group
    if group_name=='wheel':
        return HttpResponseForbidden(PERMISSION_DENIED_MESSAGE)

    # display submission form
    if request.method=='GET':
        
        status = registrationService.status(request.user.profile.openid(), group_name, ROLE_USER)
        
        licenseTxt = None
        licenseHtml = None
        try:
            licenseFile = 'cog/access_control/licenses/%s.txt' % group_name
            licenseTxt = render_to_string(licenseFile)
        except TemplateDoesNotExist:
            try:
                licenseFile = 'cog/access_control/licenses/%s.html' % group_name
                licenseHtml = render_to_string(licenseFile)
            except TemplateDoesNotExist:
                pass
        
{'fraction_non_alphanumeric': 0.06118143459915612, 'fraction_numerical': 0.0014064697609001407, 'mean_word_length': 3.7358490566037736, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5810530', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1125, 'n_words': 325}