Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
eb66a23d
authored
Feb 08, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
group creating added
parent
189bb8de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
one/views.py
+3
-1
school/views.py
+28
-0
No files found.
one/views.py
View file @
eb66a23d
...
@@ -20,6 +20,7 @@ from django.utils.translation import ugettext_lazy as _
...
@@ -20,6 +20,7 @@ from django.utils.translation import ugettext_lazy as _
from
django.views.decorators.http
import
*
from
django.views.decorators.http
import
*
from
django.views.generic
import
*
from
django.views.generic
import
*
from
one.models
import
*
from
one.models
import
*
from
school.models
import
*
import
django.contrib.auth
as
auth
import
django.contrib.auth
as
auth
from
firewall.tasks
import
*
from
firewall.tasks
import
*
import
json
import
json
...
@@ -72,7 +73,8 @@ def home(request):
...
@@ -72,7 +73,8 @@ def home(request):
return
render_to_response
(
"home.html"
,
RequestContext
(
request
,{
return
render_to_response
(
"home.html"
,
RequestContext
(
request
,{
'templates'
:
Template
.
objects
.
all
(),
'templates'
:
Template
.
objects
.
all
(),
'instances'
:
_list_instances
(
request
),
'instances'
:
_list_instances
(
request
),
'groups'
:
request
.
user
.
person_set
.
all
()[
0
]
.
owned_groups
.
all
()
'groups'
:
request
.
user
.
person_set
.
all
()[
0
]
.
owned_groups
.
all
(),
'semesters'
:
Semester
.
objects
.
all
()
}))
}))
@require_GET
@require_GET
...
...
school/views.py
View file @
eb66a23d
...
@@ -24,6 +24,7 @@ from school.models import *
...
@@ -24,6 +24,7 @@ from school.models import *
import
django.contrib.auth
as
auth
import
django.contrib.auth
as
auth
import
logging
import
logging
import
json
import
json
import
re
from
django.views.decorators.csrf
import
ensure_csrf_cookie
from
django.views.decorators.csrf
import
ensure_csrf_cookie
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -137,7 +138,34 @@ def language(request, lang):
...
@@ -137,7 +138,34 @@ def language(request, lang):
r
.
set_cookie
(
cname
,
lang
,
10
*
365
*
24
*
3600
)
r
.
set_cookie
(
cname
,
lang
,
10
*
365
*
24
*
3600
)
return
r
return
r
@login_required
def
group_show
(
request
,
gid
):
def
group_show
(
request
,
gid
):
user
=
request
.
user
user
=
request
.
user
group
=
get_object_or_404
(
Group
,
id
=
gid
)
group
=
get_object_or_404
(
Group
,
id
=
gid
)
return
render_to_response
(
"show-group.html"
,
RequestContext
(
request
,{}))
return
render_to_response
(
"show-group.html"
,
RequestContext
(
request
,{}))
def
group_new
(
request
):
name
=
request
.
POST
[
'name'
]
semester
=
Semester
.
objects
.
get
(
id
=
request
.
POST
[
'semester'
])
members_list
=
re
.
split
(
'
\r
?
\n
'
,
request
.
POST
[
'members'
])
members
=
[]
for
member
in
members_list
:
if
re
.
match
(
'^[a-zA-Z][a-zA-Z0-9]{5}$'
,
member
)
==
None
:
messages
.
error
(
request
,
_
(
'Invalid NEPTUN code found.'
))
return
redirect
(
'/'
)
try
:
user
=
User
.
objects
.
get
(
username
=
member
)
person
=
user
.
person_set
.
all
()[
0
]
except
User
.
DoesNotExist
:
pass
members
.
append
(
person
)
owner
=
request
.
user
.
person_set
.
all
()[
0
]
group
=
Group
()
group
.
name
=
name
group
.
semester
=
semester
group
.
save
()
for
member
in
members
:
group
.
members
.
add
(
person
)
group
.
owners
.
add
(
owner
)
group
.
save
()
return
redirect
(
'/group/show/
%
s'
%
group
.
id
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment