Esempio n. 1
0
 def get_queryset(self):
     search = self.request.GET.get('s', '')
     query = Content.objects.all()
     if search != '':
         words = primitivize_string(search).split(" ")
         for w in words:
             query = query.filter(primitive__contains=w)
     return query
Esempio n. 2
0
    def get_queryset(self):
        search = self.request.GET.get('s', '')
        query = Guide.objects.all()
        if search != '':
            words = primitivize_string(search).split(" ")
            for w in words:
                query = query.filter(
                    Q(primitive__contains=w)
                    | Q(items__exercise__primitive__contains=w)
                    | Q(items__content__primitive__contains=w))

        byuser = self.request.query_params.get('byuser', None)
        if byuser is not None:
            if byuser == 'me':
                query = query.filter(author=self.request.user.teacher)
            else:
                query = query.filter(author_id__exact=byuser)
        if self.action in ('list', ):
            query = [
                x for x in query if x.not_priv_or_related(self.request.user)
            ]
        return query
Esempio n. 3
0
	def make_primitive(self):
		return primitivize_string(" ".join([str(self.unit),
			str(self.author), self.briefing]))
Esempio n. 4
0
 def make_primitive(self):
     return primitivize_string(" ".join(
         [str(self.subject),
          str(self.author), self.title, self.brief]))
Esempio n. 5
0
 def make_primitive(self):
     texts = self.parse_text()
     return primitivize_string(" ".join([
         str(self.unit),
         str(self.author), self.title, self.summary, texts
     ]))