コード例 #1
0
ファイル: models.py プロジェクト: thuvh/filmmaster
 def save_activity(self):
     """
         Save new activity
     """
     from film20.useractivity.models import UserActivity
     try:
         # Checking if activity already exists for given externallink, if so update activity
         act = UserActivity.objects.get(link=self, user=self.user)
         act.url = self.url
         act.url_kind = self.url_kind
         act.video_thumb = getattr(self, "video_thumb", None)
         act.title = self.get_title()
         act.content = getattr(self, "excerpt", None)
         act.film = getattr(self, "film", None)
         act.film_title = self.film.get_title()
         act.film_permalink = self.film.permalink
         act.status = self.status
         act.permalink = self.get_absolute_url()
         act.number_of_comments = self.number_of_comments
         act.save()
     except UserActivity.DoesNotExist:
         # Activity does not exist - create a new one
         act = UserActivity()
         act.user = self.user
         act.username = self.user.username
         act.activity_type = UserActivity.TYPE_LINK
         act.link = self
         act.url = self.url
         act.url_kind = self.url_kind
         act.video_thumb = getattr(self, "video_thumb", None)
         act.title = self.get_title()
         act.content = getattr(self, "excerpt", None)
         act.film = getattr(self, "film", None)
         act.film_title = self.film.get_title()
         act.film_permalink = self.film.permalink
         act.status = self.status
         act.permalink = self.get_absolute_url()
         act.number_of_comments = self.number_of_comments
         act.save()
コード例 #2
0
ファイル: models.py プロジェクト: manlan2/filmaster
 def save_activity(self):
     """
         Save new activity
     """
     from film20.useractivity.models import UserActivity
     try:
         # Checking if activity already exists for given externallink, if so update activity
         act = UserActivity.objects.get(link=self, user=self.user)
         act.url = self.url
         act.url_kind = self.url_kind
         act.video_thumb = getattr(self, "video_thumb", None)
         act.title = self.get_title()
         act.content = getattr(self, "excerpt", None)
         act.film = getattr(self, "film", None)
         act.film_title = self.film.get_title()
         act.film_permalink = self.film.permalink
         act.status = self.status
         act.permalink = self.get_absolute_url()
         act.save()
     except UserActivity.DoesNotExist:
         # Activity does not exist - create a new one
         act = UserActivity()
         act.user = self.user
         act.username = self.user.username
         act.activity_type = UserActivity.TYPE_LINK
         act.link = self
         act.url = self.url
         act.url_kind = self.url_kind
         act.video_thumb = getattr(self, "video_thumb", None)
         act.title = self.get_title()
         act.content = getattr(self, "excerpt", None)
         act.film = getattr(self, "film", None)
         act.film_title = self.film.get_title()
         act.film_permalink = self.film.permalink
         act.status = self.status
         act.permalink = self.get_absolute_url()
         act.save()