Esempio n. 1
0
File: views.py Progetto: derks/dmirr
def update_repo(request, project, repo):
    data = {}
    repo = db.ProjectRepo.objects.get(label=repo)
    project = get_object_or_404(db.Project, label=project)
    
    if request.method == 'POST':
        form = ProjectRepoForm(request.POST, instance=repo)
        if form.is_valid():
            repo = form.save()
            
            return redirect(reverse('show_project',
                                    kwargs=dict(project=repo.project.label)))
    else:
        form = ProjectRepoForm(instance=repo)
        
    data['form'] = form   
    data['repo'] = repo 
    data['project'] = project
    return render(request, 'projects/repos/update.html', data)
Esempio n. 2
0
File: views.py Progetto: derks/dmirr
def create_repo(request, project):
    data = {}
    project = get_object_or_404(db.Project, label=project)
    
    if request.method == 'POST':
        if not session_is_owner(request):
            return Http403
            
        form = ProjectRepoForm(request.POST)
        if form.is_valid():
            repo = form.save()
            
            return redirect(reverse('show_project',
                                    kwargs=dict(project=repo.project.label)))
    else:
        form = ProjectRepoForm(initial=dict(
                            user=request.user,
                            project=project
                            ))
        
    data['form'] = form    
    data['project'] = project
    return render(request, 'projects/repos/create.html', data)
Esempio n. 3
0
def update_repo(request, project, repo):
    data = {}
    repo = db.ProjectRepo.objects.get(label=repo)
    project = get_object_or_404(db.Project, label=project)

    if request.method == 'POST':
        form = ProjectRepoForm(request.POST, instance=repo)
        if form.is_valid():
            repo = form.save()

            return redirect(
                reverse('show_project',
                        kwargs=dict(project=repo.project.label)))
    else:
        form = ProjectRepoForm(instance=repo)

    data['form'] = form
    data['repo'] = repo
    data['project'] = project
    return render(request, 'projects/repos/update.html', data)
Esempio n. 4
0
def create_repo(request, project):
    data = {}
    project = get_object_or_404(db.Project, label=project)

    if request.method == 'POST':
        if not session_is_owner(request):
            return Http403

        form = ProjectRepoForm(request.POST)
        if form.is_valid():
            repo = form.save()

            return redirect(
                reverse('show_project',
                        kwargs=dict(project=repo.project.label)))
    else:
        form = ProjectRepoForm(
            initial=dict(user=request.user, project=project))

    data['form'] = form
    data['project'] = project
    return render(request, 'projects/repos/create.html', data)