Skip to content

Commit

Permalink
New signal dispatched when an organization is created.
Browse files Browse the repository at this point in the history
Fixed bug in organization creation if your form didn't validate.
  • Loading branch information
marc-hughes committed Jan 30, 2011
1 parent ecda524 commit fb89acf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
22 changes: 22 additions & 0 deletions scrumdo-web/apps/organizations/signals.py
@@ -0,0 +1,22 @@
# ScrumDo - Agile/Scrum story management web application
# Copyright (C) 2011 ScrumDo LLC
#
# This software is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy (See file COPYING) of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


import django.dispatch

organization_created = django.dispatch.Signal(providing_args=["organization"])

9 changes: 7 additions & 2 deletions scrumdo-web/apps/organizations/views.py
Expand Up @@ -32,6 +32,8 @@
from organizations.models import *;
from organizations.team_models import *;

import organizations.signals as signals

@login_required
def organization(request, organization_slug):
organization = get_object_or_404(Organization, slug=organization_slug)
Expand Down Expand Up @@ -113,11 +115,14 @@ def organization_create(request):
default_team.members.add(request.user)
default_team.save()

signals.organization_created.send( sender=request, organization=organization )

request.user.message_set.create(message="Organization Created.")
return HttpResponseRedirect(reverse("organization_detail", kwargs={'organization_slug':organization.slug}))
else:
organizations = Organization.getOrganizationsForUser( request.user )
else:
form = OrganizationForm()

organizations = Organization.getOrganizationsForUser( request.user )

return render_to_response("organizations/create_organization.html", {
"organizations": organizations,
Expand Down

0 comments on commit fb89acf

Please sign in to comment.