Esempio n. 1
def assign_coordinators_handler(sender, **kwargs):
	members = kwargs.get('members', None)
	project = kwargs.get('project', None)

	for member in members:
		project_member = ProjectMember(member=member, project=project, is_coordinator=True, role='Coordinator')
		context = {
			'project_url': Site.objects.get_current().domain + reverse('cms:edit_project_url', kwargs={'pk':}),
			'coordinator': project_member.member.user.get_full_name()
		subject = 'Project created: %s' % project.title
		message = render_to_string('emails/project_coordinator_email.txt', context)
		send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [])
	return members
Esempio n. 2
    def save(self, commit=True):
        project = super(ModelForm, self).save(commit=False)
        # save the regular fields

        # create ProjectMember instances for members listed in form that aren't added to Project yet
        for member in self.cleaned_data.get('members', []):
            except Member.DoesNotExist:
                project_member = ProjectMember(project=project, member=member, is_coordinator=False)
                #print 'add', project_member.member.user.get_full_name()

        # delete ProjectMember instances for members listed in Project but not in form
        for member in project.members.all():
            if not member in self.cleaned_data.get('members', []):
                #print 'delete', member.user.get_full_name()

        return project