fix email bug with teams

This commit is contained in:
Luke Hatcher 2012-08-14 16:59:06 -04:00
parent 69663679cc
commit 7f0c8496c7
2 changed files with 13 additions and 1 deletions

View file

@ -20,7 +20,7 @@ class Team(models.Model):
name = models.CharField(max_length=100)
description = models.TextField(blank=True)
access = models.CharField(max_length=20, choices=TEAM_ACCESS_CHOICES)
# member permissions
permissions = models.ManyToManyField(Permission, blank=True, related_name="member_teams")
@ -29,6 +29,10 @@ class Team(models.Model):
created = models.DateTimeField(default=datetime.datetime.now, editable=False)
@models.permalink
def get_absolute_url(self):
return ("team_detail", [self.slug])
def __unicode__(self):
return self.name

View file

@ -4,6 +4,8 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from symposion.utils.mail import send_email
from symposion.teams.forms import TeamInvitationForm
from symposion.teams.models import Team, Membership
@ -63,6 +65,7 @@ def team_detail(request, slug):
form = TeamInvitationForm(request.POST, team=team)
if form.is_valid():
form.invite()
send_email([form.user.email], "teams_user_invited", context={"team": team})
messages.success(request, "Invitation created.")
return redirect("team_detail", slug=slug)
else:
@ -124,6 +127,11 @@ def team_apply(request, slug):
membership, created = Membership.objects.get_or_create(team=team, user=request.user)
membership.state = "applied"
membership.save()
managers = [m.user.email for m in team.managers()]
send_email(managers, "teams_user_applied", context={
"team": team,
"user": request.user
})
messages.success(request, "Applied to join team.")
return redirect("team_detail", slug=slug)
else: