示例#1
0
文件: upgrade.py 项目: feroda/JAGOM
    def handle(self, *args, **kw):

        if settings.VERSION[:1] == (0,1):
            try:
                default_template = Project.objects.get(slug=settings.PRJ_LINT_SLUG)
            except Project.DoesNotExist:
                # Older versions named 000-LINTENV to mean 000-LINTENV-it
                default_template = Project.objects.get(slug="000-LINTENV")
                default_template.slug = "000-LINTENV-it"
                default_template.save()

            for p in Project.objects.all():
                try:
                    assert p.relations
                except ProjectTree.DoesNotExist:
                    #Set base project (default is italian language)
                    
                    project_tree = ProjectTree(project=p, template=default_template)
                    project_tree.save()

                try:
                    assert p.profile
                except ProjectProfile.DoesNotExist:
                    project_profile = ProjectProfile(project=p, language="it")
                    project_profile.save()
示例#2
0
文件: views.py 项目: feroda/JAGOM
def create(request, form_class=ProjectTreeForm, template_name="projects/create.html"):
    project_form = form_class(request.POST or None)
    
    if project_form.is_valid():
        project = project_form.save(commit=False)
        project.creator = request.user
        project.save()
        project_member = ProjectMember(project=project, user=request.user)
        project.members.add(project_member)
        project_member.save()

        language = project_form.cleaned_data['language']
        open_updates = project_form.cleaned_data['open_updates']

        # Save profile xattr
        project_profile = ProjectProfile(project=project, 
                            language=language, 
                            open_updates=open_updates
                          )
        project_profile.save()

        # Save template and members group
        template = project_form.cleaned_data.get('template', 
                    project_profile.get_default_template()
        )
        project_tree = ProjectTree(project=project, template=template)
        project_tree.save()
#        member_groups = project_form.cleaned_data['member_groups']
#        for g in member_groups:
#            project_tree.member_groups.add(g)

        if notification:
            # @@@ might be worth having a shortcut for sending to all users
            notification.send(User.objects.all(), "projects_new_project",
                {"project": project}, queue=True)
        return HttpResponseRedirect(project.get_absolute_url())
    
    return render_to_response(template_name, {
        "project_form": project_form,
    }, context_instance=RequestContext(request))