1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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)
|