# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division

from datetime import datetime
from calendar import timegm

from django.conf import settings
from django.shortcuts import render_to_response
from django.utils.timezone import make_aware, utc

from apps.survey.models import Blockface, Survey


def js_settings(request):
    blockface_updated_at = _get_last_updated_datetime(Blockface)
    survey_updated_at = _get_last_updated_datetime(Survey)

    max_timestamp = lambda *datetimes: timegm(max(*datetimes).utctimetuple())

    return render_to_response('core/settings.js', {
        "tiler_url": settings.TILER_URL,
        "db_name": settings.DATABASES['default']['NAME'],
        "cache_buster": {
            "progress": max_timestamp(blockface_updated_at, survey_updated_at)
        }
    })


def _get_last_updated_datetime(Model):
    try:
        return Model.objects.latest('updated_at').updated_at
    except Model.DoesNotExist:
        return make_aware(datetime.min, utc)

@@ -268,16 +268,59 @@
 esponse%0A
+from django.template import RequestContext%0A
 from dja
@@ -361,16 +361,16 @@
 re, utc%0A
-
 %0Afrom ap
@@ -651,53 +651,17 @@
     
-return render_to_response('core/settings.js',
+context =
  %7B%0A 
@@ -873,21 +873,325 @@
       %7D%0A
-
     %7D
+%0A%0A    return render_to_response('core/settings.js',%0A                              context,%0A                              content_type='application/javascript',%0A                              # required to invoke the context processors%0A                              context_instance=RequestContext(request)
 )%0A%0A%0Adef 

Fix settings.js view