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
62b886fe
authored
Apr 15, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use settings api 2
parent
75d45516
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
cloud/context_processors.py
+8
-7
firewall/views.py
+22
-17
No files found.
cloud/context_processors.py
View file @
62b886fe
from
cloud.settings
import
DEBUG
,
STAT_DEBUG
,
RELEASE
from
django.core.cache
import
cache
import
subprocess
import
json
import
subprocess
from
django.conf
import
settings
from
django.core.cache
import
cache
def
process_debug
(
req
):
return
{
'DEBUG'
:
DEBUG
}
return
{
'DEBUG'
:
settings
.
DEBUG
}
def
process_stat
(
req
):
if
STAT_DEBUG
:
if
settings
.
STAT_DEBUG
:
stat
=
{
'CPU'
:
{
'USED_CPU'
:
10
,
...
...
@@ -23,11 +24,11 @@ def process_stat(req):
else
:
stat
=
cache
.
get
(
'cloud_stat'
)
return
{
'STAT_DEBUG'
:
STAT_DEBUG
,
'STAT_DEBUG'
:
settings
.
STAT_DEBUG
,
'cloud_stat'
:
stat
,
}
def
process_release
(
req
):
return
{
'release'
:
RELEASE
,
'release'
:
settings
.
RELEASE
,
}
firewall/views.py
View file @
62b886fe
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponse
from
firewall.models
import
*
from
firewall.fw
import
*
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.http
import
require_POST
from
django.db
import
IntegrityError
from
tasks
import
*
from
celery.task.control
import
inspect
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.template.loader
import
render_to_string
from
cloud.settings
import
CLOUD_URL
as
url
from
django.utils
import
translation
import
re
import
base64
import
datetime
import
json
import
re
import
sys
import
datetime
from
django.conf
import
settings
from
django.db
import
IntegrityError
from
django.http
import
HttpResponse
from
django.shortcuts
import
render_to_response
from
django.template.loader
import
render_to_string
from
django.utils
import
translation
from
django.utils.timezone
import
utc
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.http
import
require_POST
from
celery.task.control
import
inspect
from
tasks
import
*
from
firewall.fw
import
*
from
firewall.models
import
*
from
one.tasks
import
SendMailTask
def
reload_firewall
(
request
):
...
...
@@ -52,7 +53,11 @@ def firewall_api(request):
user
=
obj
.
host
.
owner
lang
=
user
.
person_set
.
all
()[
0
]
.
language
translation
.
activate
(
lang
)
msg
=
render_to_string
(
'mails/notification-ban-now.txt'
,
{
'user'
:
user
,
'bl'
:
obj
,
'instance:'
:
obj
.
host
.
instance_set
.
get
(),
'url'
:
url
}
)
msg
=
render_to_string
(
'mails/notification-ban-now.txt'
,
{
'user'
:
user
,
'bl'
:
obj
,
'instance:'
:
obj
.
host
.
instance_set
.
get
(),
'url'
:
settings
.
CLOUD_URL
}
)
SendMailTask
.
delay
(
to
=
obj
.
host
.
owner
.
email
,
subject
=
'[IK Cloud]
%
s'
%
obj
.
host
.
instance_set
.
get
()
.
name
,
msg
=
msg
,
sender
=
u'cloud@ik.bme.hu'
)
except
(
Host
.
DoesNotExist
,
ValidationError
,
IntegrityError
,
AttributeError
):
pass
...
...
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