[virtualcommons-svn] commit/vcweb: alllee: starting to work on server endpoints for lighterprints,
Status: Beta
Brought to you by:
alllee
From: Bitbucket <com...@bi...> - 2011-07-13 02:39:01
|
1 new changeset in vcweb: http://bitbucket.org/virtualcommons/vcweb/changeset/b8f3cd495b7c/ changeset: b8f3cd495b7c user: alllee date: 2011-07-13 04:38:43 summary: starting to work on server endpoints for lighterprints, some complications though: 1. figure out how to deal with django csrf appropriately from sencha touch (or bypass it by using GET instead of POST 2. still need to wire up participant + sample experiment for a lighterprints experiment. affected #: 4 files (1.7 KB) --- a/vcweb/lighterprints/urls.py Mon Jul 11 15:55:25 2011 -0700 +++ b/vcweb/lighterprints/urls.py Tue Jul 12 19:38:43 2011 -0700 @@ -1,6 +1,7 @@ from django.conf.urls.defaults import url, patterns -from vcweb.lighterprints.views import (ActivityDetailView, ActivityListView, DoActivityView, MobileView) +from vcweb.lighterprints.views import (ActivityDetailView, ActivityListView, DoActivityView, MobileView, + DiscussionBoardView) urlpatterns = patterns('vcweb.lighterprints.views', url(r'^mobile$', MobileView.as_view(), name='mobile'), @@ -8,4 +9,5 @@ url(r'^activity/list/?$', ActivityListView.as_view()), url(r'^activity/(?P<activity_id>\d+)$', ActivityDetailView.as_view()), url(r'^activity/(?P<activity_id>\d+)/do$', DoActivityView.as_view()), + url(r'^discussion/(?P<experiment_id>\d+)/(?P<participant_id>\d+)', DiscussionBoardView.as_view()), ) --- a/vcweb/lighterprints/views.py Mon Jul 11 15:55:25 2011 -0700 +++ b/vcweb/lighterprints/views.py Tue Jul 12 19:38:43 2011 -0700 @@ -1,8 +1,12 @@ +from django.shortcuts import get_object_or_404 from django.views.generic.detail import BaseDetailView from django.views.generic.edit import FormView from django.views.generic.list import BaseListView, MultipleObjectTemplateResponseMixin +from vcweb.core.models import ParticipantGroupRelationship, ChatMessage from vcweb.core.views import JSONResponseMixin +# FIXME: move to core? +from vcweb.lighterprints.forms import ChatForm from vcweb.lighterprints.models import Activity import collections @@ -15,7 +19,7 @@ model = Activity def get_context_data(self, **kwargs): - context = super(BaseListView, self).get_context_data(**kwargs) + context = super(ActivityListView, self).get_context_data(**kwargs) all_activities = context['activity_list'] activity_by_level = collections.defaultdict(list) flattened_activities = [] @@ -62,6 +66,29 @@ class DoActivityView(FormView): pass +class PostChatMessageView(FormView): + form_class = ChatForm + pass + +class DiscussionBoardView(JSONResponseMixin, MultipleObjectTemplateResponseMixin, BaseListView): + model = ChatMessage + def get_queryset(self): + # FIXME: stubbed out for now, passing in the participant id for the time + # being + # participant = self.request.user.participant + participant_id = self.kwargs['participant_id'] + experiment_id = self.kwargs['experiment_id'] +# FIXME: will change once we have proper auth set up + self.participant_group_relationship = get_object_or_404(ParticipantGroupRelationship, participant__pk=participant_id, group__experiment__pk=experiment_id) + self.group = self.participant_group_relationship.group + return ChatMessage.objects.filter(participant_group_relationship__group = self.group) + + def get_context_data(self, **kwargs): + context = super(DiscussionBoardView, self).get_context_data(**kwargs) + context['group'] = self.group + context['participant_group_relationship'] = self.participant_group_relationship + return context + def get_available_activities(request): # FIXME: currently stubbed out to return all activities. should move this to # models.py and have it take a Participant? --- a/vcweb/sanitation/fixtures/initial_data.json Mon Jul 11 15:55:25 2011 -0700 +++ b/vcweb/sanitation/fixtures/initial_data.json Tue Jul 12 19:38:43 2011 -0700 @@ -65,7 +65,9 @@ { "fields": { "name":"sanitation.pollution", - "experiment_metadata": 3, + "experiment_metadata": [ + "sanitation" + ], "creator": 4, "type": "int", "date_created": "2011-01-01 15:13:07", @@ -78,7 +80,9 @@ { "fields": { "name":"sanitation.collectedpollution", - "experiment_metadata": 3, + "experiment_metadata": [ + "sanitation" + ], "creator": 4, "type": "int", "date_created": "2011-01-01 15:13:07", Repository URL: https://bitbucket.org/virtualcommons/vcweb/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. |