Replace get_state with a variable embedded into index.html

(imported from commit 3ef4a0163107248618a25e242ab30fdff5da17e0)
This commit is contained in:
Keegan McAllister 2012-09-04 12:45:45 -04:00
parent e86216dff0
commit ac2553cdff
4 changed files with 2 additions and 14 deletions

View File

@ -9,7 +9,6 @@ import os.path
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^$', 'zephyr.views.home', name='home'), url(r'^$', 'zephyr.views.home', name='home'),
url(r'^update$', 'zephyr.views.update', name='update'), url(r'^update$', 'zephyr.views.update', name='update'),
url(r'^get_state$', 'zephyr.views.get_state', name='get_state'),
url(r'^get_updates_longpoll$', 'zephyr.views.get_updates_longpoll', name='get_updates_longpoll'), url(r'^get_updates_longpoll$', 'zephyr.views.get_updates_longpoll', name='get_updates_longpoll'),
url(r'^zephyr/', 'zephyr.views.zephyr', name='zephyr'), url(r'^zephyr/', 'zephyr.views.zephyr', name='zephyr'),
url(r'^personal-zephyr/', 'zephyr.views.personal_zephyr', name='personal_zephyr'), url(r'^personal-zephyr/', 'zephyr.views.personal_zephyr', name='personal_zephyr'),

View File

@ -12,6 +12,7 @@
<script type="text/javascript" src="/static/js/zephyr.js"></script> <script type="text/javascript" src="/static/js/zephyr.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var initial_zephyr_json = {{ zephyr_json }}; var initial_zephyr_json = {{ zephyr_json }};
var initial_pointer = {{ user_profile.pointer }};
var username = "{{ user_profile.user.username }}"; var username = "{{ user_profile.user.username }}";
</script> </script>

View File

@ -295,10 +295,8 @@ $(function () {
$.get('/static/templates/zephyr.html', function (template) { $.get('/static/templates/zephyr.html', function (template) {
ich.addTemplate('zephyr', template); ich.addTemplate('zephyr', template);
$(initial_zephyr_json).each(add_message); $(initial_zephyr_json).each(add_message);
select_zephyr($("#" + initial_pointer));
get_updates_longpoll(); get_updates_longpoll();
$.get('get_state', function(data) {
select_zephyr($("#" + data.pointer));
}, dataType="json");
}); });
}); });

View File

@ -69,16 +69,6 @@ def update(request):
user_profile.save() user_profile.save()
return HttpResponse(simplejson.dumps({}), mimetype='application/json') return HttpResponse(simplejson.dumps({}), mimetype='application/json')
@login_required
def get_state(request):
if not request.GET:
# Do something
pass
user_profile = UserProfile.objects.get(user=request.user)
return HttpResponse(simplejson.dumps({"pointer": user_profile.pointer}),
mimetype='application/json')
@asynchronous @asynchronous
def get_updates_longpoll(request, handler): def get_updates_longpoll(request, handler):
if not request.POST: if not request.POST: