예제 #1
0
파일: models.py 프로젝트: maximetit1/dri
 def get_schema(self, host_url=''):
     return {
         "@type": "CreativeWork",
         "name": self.name,
         "description": re.sub('<[^>]*>', '', self.summary),
         "dateCreated": format_date(self.created_at, '%Y-%m-%dT%H:%M'),
         "dateUpdated": format_date(self.updated_at, '%Y-%m-%dT%H:%M'),
         "discussionUrl": self.contact_url,
         "image": self.image_url,
         "license": self.event.license,
         "url": host_url + self.url
     }
예제 #2
0
파일: models.py 프로젝트: loleg/dribdat
 def get_full_data(self):
     """ Returns full JSON event content """
     d = self.data
     d['starts_at'] = format_date(self.starts_at, '%Y-%m-%dT%H:%M')
     d['ends_at'] = format_date(self.ends_at, '%Y-%m-%dT%H:%M')
     d['description'] = self.description or ''
     d['boilerplate'] = self.boilerplate or ''
     d['instruction'] = self.instruction or ''
     # And by full, we mean really full!
     d['custom_css'] = self.custom_css or ''
     d['community_embed'] = self.community_embed or ''
     d['certificate_path'] = self.certificate_path or ''
     return d
예제 #3
0
 def get_schema(self, host_url=''):
     return {
         "@context": "http://schema.org",
         "@type":"Event",
         "location":{ "@type":"Place",
             "name": self.hostname,
             "address": self.location
         },
         "name": self.name,
         "url": host_url + self.url,
         "description": re.sub('<[^>]*>', '', self.description),
         "startDate": format_date(self.starts_at, '%Y-%m-%dT%H:%M'),
         "endDate": format_date(self.ends_at, '%Y-%m-%dT%H:%M'),
         "logo": self.logo_url,
         "mainEntityOfPage": self.webpage_url,
         "offers":{ "@type":"Offer", "url": self.webpage_url },
         "workPerformed":[ p.get_schema(host_url) for p in self.projects ]
     }
예제 #4
0
파일: models.py 프로젝트: loleg/dribdat
 def data(self):
     d = {
         'id': self.id,
         'url': self.url,
         'name': self.name,
         'team': self.team,
         'score': self.score,
         'phase': self.phase,
         'is_challenge': self.is_challenge,
         'progress': self.progress,
         'summary': self.summary or '',
         'hashtag': self.hashtag or '',
         'image_url': self.image_url or '',
         'source_url': self.source_url or '',
         'webpage_url': self.webpage_url or '',
         'autotext_url': self.autotext_url or '',
         'download_url': self.download_url or '',
         'contact_url': self.contact_url or '',
         'logo_color': self.logo_color or '',
         'logo_icon': self.logo_icon or '',
         'excerpt': '',
     }
     d['created_at'] = format_date(self.created_at, '%Y-%m-%dT%H:%M')
     d['updated_at'] = format_date(self.updated_at, '%Y-%m-%dT%H:%M')
     # Generate excerpt based on summary data
     if self.longtext and len(self.longtext) > 10:
         d['excerpt'] = self.longtext[:MAX_EXCERPT_LENGTH]
         if len(self.longtext) > MAX_EXCERPT_LENGTH:
             d['excerpt'] += '...'
     elif self.is_autoupdateable:
         if self.autotext and len(self.autotext) > 10:
             d['excerpt'] = self.autotext[:MAX_EXCERPT_LENGTH]
             if len(self.autotext) > MAX_EXCERPT_LENGTH:
                 d['excerpt'] += '...'
     if self.user is not None:
         d['maintainer'] = self.user.username
     if self.event is not None:
         d['event_url'] = self.event.url
         d['event_name'] = self.event.name
     if self.category is not None:
         d['category_id'] = self.category.id
         d['category_name'] = self.category.name
     return d
예제 #5
0
파일: models.py 프로젝트: loleg/dribdat
 def get_schema(self, host_url=''):
     """ Schema.org compatible metadata """
     # TODO: accurately detect project license based on component etc.
     if not self.event.community_embed:
         content_license = ''
     elif "creativecommons" in self.event.community_embed:
         content_license = "https://creativecommons.org/licenses/by/4.0/"
     else:
         content_license = ''
     cleansummary = None
     if self.summary:
         cleansummary = re.sub('<[^>]*>', '', self.summary)
     return {
         "@type": "CreativeWork",
         "name": self.name,
         "description": cleansummary,
         "dateCreated": format_date(self.created_at, '%Y-%m-%dT%H:%M'),
         "dateUpdated": format_date(self.updated_at, '%Y-%m-%dT%H:%M'),
         "discussionUrl": self.contact_url,
         "image": self.image_url,
         "license": content_license,
         "url": host_url + self.url
     }
예제 #6
0
파일: models.py 프로젝트: loleg/dribdat
 def get_schema(self, host_url=''):
     """ Returns hackathon.json formatted metadata """
     desc = self.summary or re.sub('<[^>]*>', '', self.description or '')
     d = {
         "@context": "http://schema.org",
         "@type": "Event",
         "name": self.name,
         "url": host_url + self.url,
         "description": desc,
         "startDate": format_date(self.starts_at, '%Y-%m-%dT%H:%M'),
         "endDate": format_date(self.ends_at, '%Y-%m-%dT%H:%M'),
         "workPerformed": [p.get_schema(host_url) for p in self.projects]
     }
     if self.hostname and self.location:
         d["location"] = {
             "@type": "Place",
             "name": self.hostname, "address": self.location
         }
     if self.logo_url:
         d["logo"] = self.logo_url
     if self.webpage_url:
         d["mainEntityOfPage"] = self.webpage_url
         d["offers"] = {"@type": "Offer", "url": self.webpage_url}
     return d
예제 #7
0
파일: models.py 프로젝트: loleg/dribdat
 def data(self):
     localtime = current_app.tz.localize(self.timestamp)
     a = {
         'id': self.id,
         'time': int(mktime(self.timestamp.timetuple())),
         'date': format_date(localtime, '%Y-%m-%dT%H:%M'),
         'timesince': timesince(localtime),
         'name': self.name,
         'action': self.action or '',
         'content': self.content or '',
         'ref_url': self.ref_url or '',
     }
     if self.user:
         a['user_id'] = self.user.id
         a['user_name'] = self.user.username
     if self.project:
         a['project_id'] = self.project.id
         a['project_name'] = self.project.name
         a['project_score'] = self.project_score or 0
         a['project_phase'] = getProjectPhase(self.project)
     return a