Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Respect My Net
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
piks3l
Respect My Net
Commits
0a0ae097
Commit
0a0ae097
authored
Apr 30, 2011
by
stef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[enh] storage of reports
parent
2905e87d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
22 deletions
+48
-22
bt/models.py
bt/models.py
+10
-10
bt/views.py
bt/views.py
+38
-12
No files found.
bt/models.py
View file @
0a0ae097
...
...
@@ -48,20 +48,10 @@ MEDIA = (
(
'mobile'
,
_
(
'Mobile'
)),
)
class
Attachment
(
models
.
Model
):
attachment
=
models
.
FileField
(
upload_to
=
'static'
)
class
Comment
(
models
.
Model
):
submitter
=
models
.
EmailField
()
comment
=
models
.
TextField
()
date
=
models
.
DateField
()
attachments
=
models
.
ForeignKey
(
Attachment
)
class
Violation
(
models
.
Model
):
country
=
models
.
CharField
(
max_length
=
2
,
choices
=
COUNTRIES
)
operator
=
models
.
CharField
(
max_length
=
256
)
contract
=
models
.
CharField
(
max_length
=
256
)
comments
=
models
.
ForeignKey
(
Comment
)
resource
=
models
.
CharField
(
max_length
=
1
,
choices
=
RESOURCES
)
type
=
models
.
CharField
(
max_length
=
1
,
choices
=
TYPES
)
media
=
models
.
CharField
(
max_length
=
1
,
choices
=
MEDIA
)
...
...
@@ -69,3 +59,13 @@ class Violation(models.Model):
contractual
=
models
.
BooleanField
()
contract_excerpt
=
models
.
TextField
()
loophole
=
models
.
BooleanField
()
class
Comment
(
models
.
Model
):
submitter
=
models
.
EmailField
()
comment
=
models
.
TextField
()
timestamp
=
models
.
DateField
()
violation
=
models
.
ForeignKey
(
Violation
)
class
Attachment
(
models
.
Model
):
storage
=
models
.
FileField
(
upload_to
=
'static'
)
comment
=
models
.
ForeignKey
(
Comment
)
bt/views.py
View file @
0a0ae097
...
...
@@ -2,21 +2,47 @@ from forms import AddViolation
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
Http404
from
django.shortcuts
import
render_to_response
from
django.template
import
RequestContext
from
models
import
Violation
import
json
from
django.core.files
import
File
from
django.conf
import
settings
from
models
import
Violation
,
Attachment
,
Comment
from
tempfile
import
mkstemp
from
datetime
import
datetime
import
hashlib
,
os
def
add
(
request
):
if
request
.
method
==
'POST'
:
# If the form has been submitted...
form
=
AddViolation
(
request
.
POST
)
# A form bound to the POST data
if
form
.
is_valid
():
# All validation rules pass
# Process the data in form.cleaned_data
# ...
print
'asdf'
,
form
.
cleaned_data
if
request
.
method
==
'POST'
:
form
=
AddViolation
(
request
.
POST
)
if
form
.
is_valid
():
v
=
Violation
(
country
=
form
.
cleaned_data
[
'country'
],
operator
=
form
.
cleaned_data
[
'operator'
],
contract
=
form
.
cleaned_data
[
'contract'
],
resource
=
form
.
cleaned_data
[
'resource'
],
type
=
form
.
cleaned_data
[
'type'
],
media
=
form
.
cleaned_data
[
'media'
],
temporary
=
form
.
cleaned_data
[
'temporary'
],
contractual
=
form
.
cleaned_data
[
'contractual'
],
contract_excerpt
=
form
.
cleaned_data
[
'contract_excerpt'
],
loophole
=
form
.
cleaned_data
[
'loophole'
]
)
v
.
save
()
c
=
Comment
(
comment
=
form
.
cleaned_data
[
'comment'
],
submitter
=
form
.
cleaned_data
[
'email'
],
timestamp
=
datetime
.
now
(),
violation
=
v
,
)
c
.
save
()
for
f
in
request
.
FILES
.
getlist
(
'attachments[]'
):
a
=
Attachment
(
comment
=
c
)
a
.
storage
.
save
(
f
.
name
,
f
)
a
.
save
()
return
HttpResponseRedirect
(
'/'
)
# Redirect after POST
else
:
form
=
AddViolation
()
# An unbound form
form
=
AddViolation
()
return
render_to_response
(
'add.html'
,
return
render_to_response
(
'add.html'
,
{
'form'
:
form
,
},
context_instance
=
RequestContext
(
request
))
...
...
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