From: Guillaume Pellerin Date: Tue, 25 Jun 2013 20:22:58 +0000 (+0200) Subject: update conf synchronisation (push/pull) X-Git-Tag: 1.1~607 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f9e4110e60cabe45a4984aea663745134263eb5c;p=teleforma.git update conf synchronisation (push/pull) --- diff --git a/teleforma/models/core.py b/teleforma/models/core.py index af0e7d1a..bc0c126c 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -248,11 +248,11 @@ class Conference(Model): def __unicode__(self): return self.description - def save(self, **kwargs): - super(Conference, self).save(**kwargs) + def save(self, *args, **kwargs): if not self.public_id: self.public_id = get_random_hash() self.course.save() + super(Conference, self).save(*args, **kwargs) def to_dict(self): dict = [{'id':'public_id','value': self.public_id, 'class':'', 'label': 'public_id'}, diff --git a/teleforma/views/core.py b/teleforma/views/core.py index 5756204e..77b61fbb 100644 --- a/teleforma/views/core.py +++ b/teleforma/views/core.py @@ -394,14 +394,7 @@ class ConferenceView(DetailView): return super(ConferenceView, self).dispatch(*args, **kwargs) -class ConferenceListView(ListView): - - model = Conference - template_name='teleforma/conferences.html' - - def get_queryset(self): - conferences = Conference.objects.all() - return conferences +class ConferenceListView(View): @jsonrpc_method('teleforma.get_conference_list') def get_conference_list(request): @@ -415,13 +408,26 @@ class ConferenceListView(ListView): url = 'http://' + settings.TELECASTER_MASTER_SERVER + '/json/' s = ServiceProxy(url) - result = s.teleforma.get_conference_list() - for conf_dict in result['result']: + remote_list = s.teleforma.get_conference_list() + for conf_dict in remote_list['result']: conference = Conference.objects.filter(public_id=conf_dict['id']) if not conference: conference = Conference() conference.from_json_dict(conf_dict) + def push(request, host=None): + if not host: + host = settings.TELECASTER_MASTER_SERVER + url = 'http://' + host + '/json/' + + s = ServiceProxy(url) + remote_list = s.teleforma.get_conference_list()['result'] + remote_ids = [conf['id'] for conf in remote_list] + + for conference in Conference.objects.all(): + if not conference.public_id in remote_ids and conference.date_end: + s.teleforma.create_conference(conference.to_json_dict()) + class ConferenceRecordView(FormView): "Conference record form : TeleCaster module required"