diff options
Diffstat (limited to 'python/projects/views.py')
-rw-r--r-- | python/projects/views.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/python/projects/views.py b/python/projects/views.py new file mode 100644 index 0000000..522da80 --- /dev/null +++ b/python/projects/views.py @@ -0,0 +1,86 @@ +from django.shortcuts import render +from django.http import HttpResponseRedirect + +from www.utils import default_siteinfo +from .models import Projects +from .forms import NewProjectForm + +def index(request): + menyrequest = 'projects' + siteinfo = default_siteinfo(request, menyrequest) + for meny in siteinfo['submenys']: + if meny.title == 'Add': + meny.view = True + else: + meny.view = False + siteinfo['subactivemeny'] = False + siteinfo['Projects'] = Projects.objects.all() + htmlrequest = 'pages/' + menyrequest + '/index.html' + return render(request, htmlrequest, siteinfo) + +def detail(request, project_uuid): + menyrequest = 'projects' + submenyrequest = 'detail' + siteinfo = default_siteinfo(request, menyrequest) + for meny in siteinfo['submenys']: + if meny.title == 'Add': + meny.view = True + if meny.title == 'Edit': + meny.view = True + siteinfo['subactivemeny'] = submenyrequest + siteinfo['Projects'] = Projects.objects.get(uuid = project_uuid) + htmlrequest = 'pages/' + menyrequest + '/' + submenyrequest + '/index.html' + return render(request, htmlrequest, siteinfo) + +def add(request): + if request.method == 'POST': + # create a form instance and populate it with data from the request: + form = NewProjectForm(request.POST) + # check whether it's valid: + if form.is_valid(): + # process the data in form.cleaned_data as required + # ... + # redirect to a new URL: + a = form.save() + project = Projects.objects.get(name=a.name) + print(project) + detail(request, project.uuid) + else: + menyrequest = 'projects' + submenyrequest = 'add' + siteinfo = default_siteinfo(request, menyrequest) + siteinfo['Form'] = NewProjectForm() + for meny in siteinfo['submenys']: + if meny.title == 'Add': + meny.view = True + if meny.title == 'Edit': + meny.view = False + siteinfo['subactivemeny'] = submenyrequest + htmlrequest = 'pages/' + menyrequest + '/' + submenyrequest + '/index.html' + return render(request, htmlrequest, siteinfo) + +def repos(request, project_uuid): + menyrequest = 'projects' + submenyrequest = 'repos' + siteinfo = default_siteinfo(request, menyrequest) + for meny in siteinfo['subpages']: + if meny.title == 'Add': + meny.view = True + if meny.title == 'Edit': + meny.view = True + siteinfo['subactivemeny'] = submenyrequest + siteinfo['Project'] = Projects.objects.filter(uuid = project_uuid) + siteinfo['Projects_repos_e'] = ProjectsRepos.objects.filter(project__uuid = project_uuid).filter(repo__type ='ebuild') + siteinfo['Projects_repos_p'] = ProjectsRepos.objects.filter(project__uuid = project_uuid).filter(repo__type ='project') + htmlrequest = 'pages/' + menyrequest + '/' + submenyrequest + '/index.html' + return render(request, htmlrequest, siteinfo) + +def requests(request, project_uuid): + menyrequest = 'projects' + submenyrequest = 'requests' + siteinfo = default_siteinfo(request, menyrequest) + +def users(request, project_uuid): + menyrequest = 'projects' + submenyrequest = 'users' + siteinfo = default_siteinfo(request, menyrequest) |