def notify(self): from film20.useractivity.models import UserActivity profile = self.user.get_profile() tz = profile.timezone_id and pytz.timezone( profile.timezone_id) or pytz.utc data = { 'checkin': self, 'user': self.user, 'screening': self.screening, 'time': self.screening and self.screening.get_local_time(tz), 'film': self.film or self.screening and self.screening.film, 'channel': self.screening and self.screening.channel, 'link': self.screening and self.screening.get_absolute_url() or self.film and self.film.get_absolute_url(), 'hashtags': self.film and UserActivity.get_hashtags(self.film), 'url': self.get_absolute_url(), } if self.film: data['picture'] = self.film.get_absolute_image_url() status = self.status == self.ACTIVE and "check_in" or "check_in_cancel" send_notice([self.user], "useractivity_" + status, data) followers = set(self.user.followers.followers()) send_notice(followers, "showtimes_following_" + status, data) if self.screening: screening_users = User.objects.filter( screeningcheckin__screening=self.screening).exclude( id=self.user_id) send_notice(screening_users, "showtimes_screening_" + status, data) if self.screening.channel.type == TYPE_CINEMA: # TODO - select only user near this cinema near_cinema_users = set( User.objects.filter( selected_channels=self.screening.channel).exclude( id=self.user_id)) logger.info("near users: %r", near_cinema_users) near_followers = near_cinema_users.intersection(followers) logger.info("near followers: %r", near_followers) send_notice(near_cinema_users, "showtimes_near_cinema_" + status, data) send_notice(near_followers, "showtimes_following_near_cinema_" + status, data)
def notify(self): from film20.useractivity.models import UserActivity profile = self.user.get_profile() tz = profile.timezone_id and pytz.timezone(profile.timezone_id) or pytz.utc data = { 'checkin':self, 'user':self.user, 'screening':self.screening, 'time':self.screening and self.screening.get_local_time(tz), 'film':self.film or self.screening and self.screening.film, 'channel':self.screening and self.screening.channel, 'link': self.screening and self.screening.get_absolute_url() or self.film and self.film.get_absolute_url(), 'hashtags': self.film and UserActivity.get_hashtags(self.film), 'url': self.get_absolute_url(), } if self.film: data['picture'] = self.film.get_absolute_image_url() status = self.status == self.ACTIVE and "check_in" or "check_in_cancel" send_notice([self.user], "useractivity_" + status, data) followers = set(self.user.followers.followers()) send_notice(followers, "showtimes_following_" + status, data) if self.screening: screening_users = User.objects.filter(screeningcheckin__screening=self.screening).exclude(id=self.user_id) send_notice(screening_users, "showtimes_screening_" + status, data) if self.screening.channel.type == TYPE_CINEMA: # TODO - select only user near this cinema near_cinema_users = set(User.objects.filter(selected_channels=self.screening.channel).exclude(id=self.user_id)) logger.info("near users: %r", near_cinema_users) near_followers = near_cinema_users.intersection(followers) logger.info("near followers: %r", near_followers) send_notice(near_cinema_users, "showtimes_near_cinema_" + status, data) send_notice(near_followers, "showtimes_following_near_cinema_" + status, data)
def send_notification(sender, instance, created, *args, **kw): data = { 'summary_id': instance.id, } send_notice([instance.user], "import_ratings_log", data)
def send_import_failed_notification( self ): send_notice( [self.user], "import_ratings_failed", {} )
def send_import_failed_notification(self): send_notice([self.user], "import_ratings_failed", {})
def send_notification(sender, instance, created, *args, **kw): data = { 'link_to_ratings': "http://" + str(instance.user) + "." + settings.DOMAIN + reverse('ratings'), 'link_to_summary': "http://" + settings.DOMAIN + reverse('import_summary', args=[instance.id]), } send_notice([instance.user], "import_ratings_log", data)