示例#1
0
文件: forms.py 项目: codeflow/pinax
from django import forms
from django.conf import settings
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _, ugettext
from django.utils.encoding import smart_unicode
from django.utils.hashcompat import sha_constructor
from django.utils.http import int_to_base36

from django.contrib import messages
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.contrib.auth.tokens import default_token_generator
from django.contrib.sites.models import Site

from pinax.core.utils import get_send_mail
send_mail = get_send_mail()

from emailconfirmation.models import EmailAddress
from timezones.forms import TimeZoneField

from pinax.apps.account.models import Account, PasswordReset
from pinax.apps.account.models import OtherServiceInfo, other_service, update_other_services
from pinax.apps.account.utils import user_display



alnum_re = re.compile(r"^\w+$")


# @@@ might want to find way to prevent settings access globally here.
REQUIRED_EMAIL = getattr(settings, "ACCOUNT_REQUIRED_EMAIL", False)
示例#2
0
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from django.http import HttpResponse
from django.core import serializers
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.forms.fields import email_re
import random
import string

from projects.models import Project
from organizations.forms import *
from organizations.models import *
from pinax.core.utils import get_send_mail
from pinax.core.utils import get_send_mail
send_mail = get_send_mail()



def _isAdmin( user, organization ):
    return Organization.objects.filter( teams__members = user , teams__access_type="admin", teams__organization=organization).count() > 0

@login_required
def team_add_project(request, organization_slug, team_id ):
    organization = get_object_or_404(Organization, slug=organization_slug)    
    if not organization.hasStaffAccess( request.user ):
        raise PermissionDenied()
    team = get_object_or_404(Team, id=team_id)
    if team.organization != organization:
        raise PermissionDenied() # Shenanigans
    project_id = request.POST.get("project")