Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions devenv/docker/blocks/graphite09/files/events_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,20 @@ def default(self, obj):

def view_events(request):
if request.method == "GET":
context = { 'events' : fetch(request),
'slash' : get_script_prefix()
}
context = {"events": fetch(request), "slash": get_script_prefix()}
return render_to_response("events.html", context)
else:
return post_event(request)


def detail(request, event_id):
e = get_object_or_404(models.Event, pk=event_id)
context = { 'event' : e,
'slash' : get_script_prefix()
}
context = {"event": e, "slash": get_script_prefix()}
return render_to_response("event.html", context)


def post_event(request):
if request.method == 'POST':
if request.method == "POST":
event = json.loads(request.body)
assert isinstance(event, dict)

Expand All @@ -60,29 +57,35 @@ def post_event(request):
else:
return HttpResponse(status=405)


def get_data(request):
if 'jsonp' in request.REQUEST:
if "jsonp" in request.REQUEST:
response = HttpResponse(
"%s(%s)" % (request.REQUEST.get('jsonp'),
json.dumps(fetch(request), cls=EventEncoder)),
mimetype='text/javascript')
"%s(%s)"
% (
request.REQUEST.get("jsonp"),
json.dumps(fetch(request), cls=EventEncoder),
),
mimetype="text/javascript",
)
else:
response = HttpResponse(
json.dumps(fetch(request), cls=EventEncoder),
mimetype="application/json")
json.dumps(fetch(request), cls=EventEncoder), mimetype="application/json"
)
return response


def fetch(request):
#XXX we need to move to USE_TZ=True to get rid of naive-time conversions
# XXX we need to move to USE_TZ=True to get rid of naive-time conversions
def make_naive(dt):
if 'tz' in request.GET:
tz = timezone(request.GET['tz'])
else:
tz = get_current_timezone()
local_dt = dt.astimezone(tz)
if hasattr(local_dt, 'normalize'):
local_dt = local_dt.normalize()
return local_dt.replace(tzinfo=None)
if "tz" in request.GET:
tz = timezone(request.GET["tz"])
else:
tz = get_current_timezone()
local_dt = dt.astimezone(tz)
if hasattr(local_dt, "normalize"):
local_dt = local_dt.normalize()
return local_dt.replace(tzinfo=None)

if request.GET.get("from", None) is not None:
time_from = make_naive(parseATTime(request.GET["from"]))
Expand All @@ -98,5 +101,6 @@ def make_naive(dt):
if tags is not None:
tags = request.GET.get("tags").split(" ")

return [x.as_dict() for x in
models.Event.find_events(time_from, time_until, tags=tags)]
return [
x.as_dict() for x in models.Event.find_events(time_from, time_until, tags=tags)
]
46 changes: 23 additions & 23 deletions devenv/docker/blocks/graphite09/files/local_settings.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Edit this file to override the default graphite settings, do not edit settings.py

# Turn on debugging and restart apache if you ever see an "Internal Server Error" page
#DEBUG = True
# DEBUG = True

# Set your local timezone (django will try to figure this out automatically)
TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

# Setting MEMCACHE_HOSTS to be empty will turn off use of memcached entirely
#MEMCACHE_HOSTS = ['127.0.0.1:11211']
# MEMCACHE_HOSTS = ['127.0.0.1:11211']

# Sometimes you need to do a lot of rendering work but cannot share your storage mount
#REMOTE_RENDERING = True
#RENDERING_HOSTS = ['fastserver01','fastserver02']
#LOG_RENDERING_PERFORMANCE = True
#LOG_CACHE_PERFORMANCE = True
# REMOTE_RENDERING = True
# RENDERING_HOSTS = ['fastserver01','fastserver02']
# LOG_RENDERING_PERFORMANCE = True
# LOG_CACHE_PERFORMANCE = True

# If you've got more than one backend server they should all be listed here
#CLUSTER_SERVERS = []
# CLUSTER_SERVERS = []

# Override this if you need to provide documentation specific to your graphite deployment
#DOCUMENTATION_URL = "http://wiki.mycompany.com/graphite"
# DOCUMENTATION_URL = "http://wiki.mycompany.com/graphite"

# Enable email-related features
#SMTP_SERVER = "mail.mycompany.com"
# SMTP_SERVER = "mail.mycompany.com"

# LDAP / ActiveDirectory authentication setup
#USE_LDAP_AUTH = True
#LDAP_SERVER = "ldap.mycompany.com"
#LDAP_PORT = 389
#LDAP_SEARCH_BASE = "OU=users,DC=mycompany,DC=com"
#LDAP_BASE_USER = "CN=some_readonly_account,DC=mycompany,DC=com"
#LDAP_BASE_PASS = "readonly_account_password"
#LDAP_USER_QUERY = "(username=%s)" #For Active Directory use "(sAMAccountName=%s)"
# USE_LDAP_AUTH = True
# LDAP_SERVER = "ldap.mycompany.com"
# LDAP_PORT = 389
# LDAP_SEARCH_BASE = "OU=users,DC=mycompany,DC=com"
# LDAP_BASE_USER = "CN=some_readonly_account,DC=mycompany,DC=com"
# LDAP_BASE_PASS = "readonly_account_password"
# LDAP_USER_QUERY = "(username=%s)" #For Active Directory use "(sAMAccountName=%s)"

# If sqlite won't cut it, configure your real database here (don't forget to run manage.py syncdb!)
#DATABASE_ENGINE = 'mysql' # or 'postgres'
#DATABASE_NAME = 'graphite'
#DATABASE_USER = 'graphite'
#DATABASE_PASSWORD = 'graphite-is-awesome'
#DATABASE_HOST = 'mysql.mycompany.com'
#DATABASE_PORT = '3306'
# DATABASE_ENGINE = 'mysql' # or 'postgres'
# DATABASE_NAME = 'graphite'
# DATABASE_USER = 'graphite'
# DATABASE_PASSWORD = 'graphite-is-awesome'
# DATABASE_HOST = 'mysql.mycompany.com'
# DATABASE_PORT = '3306'
Loading