def slug(self):
return slugify(self.__unicode__())
+ def to_dict(self):
+ dict = {'organization' : self.department.organization.name,
+ 'department' : self.department.name,
+ 'title' : self.title,
+ 'description' : self.description,
+ 'code' : self.code,
+ 'title_tweeter' : self.title_tweeter,
+ 'number' : str(self.number),
+ ]
+ return dict
+
+ def from_dict(self, data):
+ organization, c = Organization.objects.get_or_create(name=data['organization'])
+ self.department, c = Department.objects.get_or_create(name=data['department'], organization=organization)
+ self.title = data['title']
+ self.description = data['description']
+ self.code = date['code']
+ self.title_tweeter = data['title_tweeter']
+ self.number = int(data['number'])
+ self.save()
+
class Meta(MetaCore):
db_table = app_label + '_' + 'course'
verbose_name = _('course')
def dispatch(self, *args, **kwargs):
return super(CourseListView, self).dispatch(*args, **kwargs)
+ @jsonrpc_method('teleforma.get_all_courses')
+ def get_dep_courses(request):
+ return [course.to_dict() for course in Course.objects.all()]
+
class CourseView(CourseAccessMixin, DetailView):
def dispatch(self, *args, **kwargs):
return super(CourseView, self).dispatch(*args, **kwargs)
- @jsonrpc_method('teleforma.get_dep_courses')
- def get_dep_courses(request, id):
- department = Department.objects.get(id=id)
- return [{'id': str(c.id), 'name': unicode(c)} for c in department.course.all()]
-
- @jsonrpc_method('teleforma.get_dep_periods')
- def get_dep_periods(request, id):
- department = Department.objects.get(id=id)
- return [{'id': str(c.id), 'name': unicode(c)} for c in department.period.all()]
-
class MediaView(CourseAccessMixin, DetailView):
s = ServiceProxy(url)
s.teleforma.create_conference(self.conference.to_json_dict())
+ @jsonrpc_method('teleforma.get_dep_courses')
+ def get_dep_courses(request, id):
+ department = Department.objects.get(id=id)
+ return [{'id': str(c.id), 'name': unicode(c)} for c in department.course.all()]
+
+ @jsonrpc_method('teleforma.get_dep_periods')
+ def get_dep_periods(request, id):
+ department = Department.objects.get(id=id)
+ return [{'id': str(c.id), 'name': unicode(c)} for c in department.period.all()]
class ProfessorListView(View):