def create_project(self, vcs_alias=None, workflow=None, *args, **kwargs): """ Creates new project and call it's setup function by sending :signal:`setup_project` signal. """ instance = self.create(*args, **kwargs) setup_project.send(sender=self.model, instance=instance, vcs_alias=vcs_alias, workflow=workflow) return instance
def save(self, commit=True): instance = super(ProjectCreateForm, self).save(commit=False) if commit: instance.save() setup_project.send(sender=Project, instance=instance, vcs_alias=self.cleaned_data.get('vcs_alias', None)) for team in self.cleaned_data.get('teams', ()): team.project = instance team.save() return instance
def save(self, commit=True): instance = super(ProjectCreateForm, self).save(commit=False) if commit: instance.save() setup_project.send(sender=Project, instance=instance, vcs_alias=self.cleaned_data.get( 'vcs_alias', None)) for team in self.cleaned_data.get('teams', ()): team.project = instance team.save() return instance
def response(self, request, username, project_slug): user_fork = self.project.get_fork_for_user(request.user) if user_fork: messages.warning(request, _("User has already forked this project")) return redirect(user_fork.get_absolute_url()) form = ProjectForkForm(request.POST or None) if request.method == 'POST': if form.is_valid(): # TODO: Move can_create from ProjectCreateView class ProjectCreateView.can_create(request.user, request) try: fork = self.project.fork(user=request.user) setup_project.send(sender=Project, instance=fork) return redirect(fork.get_absolute_url()) except ProjectorError, err: messages.error(request, str(err)) return redirect(self.project.get_absolute_url())