Пример #1
0
    def run(self):
        query = Student.all().filter('is_participant =', True).run(limit=600)
        unit = self.unit
        for student in query:
            # TODO use defaultdict('') instead of local vars?
            unit_page = WikiPage.get_page(student, unit=unit)
            posted_unit = bool(unit_page)
            num_endorsements = num_exemplaries = num_comments = ''
            if unit_page:
                num_endorsements = Annotation.endorsements(
                    what=unit_page).count()
                num_exemplaries = Annotation.exemplaries(
                    what=unit_page).count()
                num_comments = WikiComment.all().filter('topic',
                                                        unit_page).count()
                fields = viewable_model(unit_page)
            else:
                fields = {}

            num_given = Annotation.endorsements(who=student, unit=unit).count()
            exemps_given = Annotation.exemplaries(who=student,
                                                  unit=unit).count()

            info = {
                'email':
                student.key().name(),
                'name':
                student.name,
                'unit':
                unit,
                'group_id':
                student.group_id,
                'posted_unit':
                posted_unit,
                'endorsements_received':
                num_endorsements,
                'endorsements_given':
                num_given,
                'exemplaries_received':
                num_exemplaries,
                'exemplaries_given':
                exemps_given,
                'num_comments':
                num_comments,
                'link':
                Markup('<a href="%s%s?%s">link</a>') %
                (self.request.host_url, '/wiki',
                 urllib.urlencode({
                     'unit': unit,
                     'student': student.wiki_id,
                     'action': 'view'
                 })),
            }
            info.update(
                {k: re.sub(r'<[^>]*?>', '', v)
                 for k, v in fields.items()})
            #info.update(fields)
            yield info
Пример #2
0
    def run(self):
        query = Student.all().filter('is_participant =', True).run(limit=600)
        unit = self.unit
        for student in query:
            # TODO use defaultdict('') instead of local vars?
            unit_page = WikiPage.get_page(student, unit=unit)
            posted_unit = bool(unit_page)
            num_endorsements = num_exemplaries = num_comments = ''
            if unit_page:
                num_endorsements = Annotation.endorsements(what=unit_page).count()
                num_exemplaries = Annotation.exemplaries(what=unit_page).count()
                num_comments = WikiComment.all().filter('topic', unit_page).count()
                fields = viewable_model(unit_page)
            else:
                fields = {}

            num_given = Annotation.endorsements(who=student, unit=unit).count()
            exemps_given = Annotation.exemplaries(who=student, unit=unit).count()

            info = {
                    'email': student.key().name(),
                    'name': student.name,
                    'unit': unit,
                    'group_id': student.group_id,
                    'posted_unit': posted_unit,
                    'endorsements_received': num_endorsements,
                    'endorsements_given': num_given,
                    'exemplaries_received': num_exemplaries,
                    'exemplaries_given': exemps_given,
                    'num_comments': num_comments,
                    'link': Markup('<a href="%s%s?%s">link</a>') % (
                        self.request.host_url,
                        '/wiki',
                        urllib.urlencode({
                            'unit': unit,
                            'student': student.wiki_id,
                            'action': 'view'
                            })),
                    }
            info.update({k: re.sub(r'<[^>]*?>', '', v) for k, v in fields.items()})
            #info.update(fields)
            yield info
Пример #3
0
 def wikipage_to_dict(self, entity):
     info = dict()
     info['email'] = entity.author_email
     d = viewable_model(entity)
     info.update({k: re.sub(r'<[^>]*?>', '', v) for k, v in d.items()})
     return info
Пример #4
0
 def wikipage_to_dict(self, entity):
     info = dict()
     info['email'] = entity.author_email
     d = viewable_model(entity)
     info.update({k: re.sub(r'<[^>]*?>', '', v) for k, v in d.items()})
     return info