def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: # notify a user user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) # send notification to user here. hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: #notify a user user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) #send notification to user here hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def post_save_tweet_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) print(usernames) hashtag_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hashtag_regex, instance.content) print(hashtags) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: # Notify the user user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) # username = m.group("username") # print(username) # Send notification now! hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: user_regex = r'@(?P<username>[\w.@+-]+)' username = re.findall(user_regex, instance.content) # if m: # username = m.group("username") # print(username) # #alert(); hash_regex = r'#(?P<hashtag>[\w.\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweetSaveReceiver(sender, instance, created, *args, **kwargs): if created and not instance.parentTweet: # notify a user userRegex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(userRegex, instance.tweetText) #print(usernames) #send notification to user. hashTagRegex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hashTagRegex, instance.tweetText) #print(hashtags) #send hashtag signal to user. parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, **kwargs): if created and not instance.parent: user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) for u in usernames: qs = User.objects.filter(username__iexact=u) if qs.exists(): user_obj = qs.first() mentioned_tweet_mail.delay(user_obj.email, instance.pk) hashtag_regex = r'#(?P<hashtag>[\w\d+-]+)' hashtags = re.findall(hashtag_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_reciver(sender, instance, created, *args, **kwargs): if created and not instance.parent: #notify user user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) #m ,match #send anotification to user here #send hashtag signal to user here hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) #m ,match find all hashtags parsed_hashtags.send( sender=instance.__class__, hashtag_list=hashtags ) #send them to hashtag app and in hashtag model there are a reciver,,__class__ it refer to class of this instance (datamodel decumentaion)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): ''' using Django signals to send notifications to the user such as updating the hashtags list in the db when they are created and even before they are user -clicked- ''' if created and not instance.parent: user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): ''' using Django signals to send notifications to the user such as updating the hashtags list in the db when they are created and even before they are user -clicked- ''' if created and not instance.parent: user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: user_regex = r'@(?P<username>[\w.@+-]+)' usernames = re.findall(user_regex, instance.content) # if m: # username = m.group("username") # send notification to user here hashtag_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hashtag_regex, instance.content) # if hashtag_m: # hashtag = hashtag_m.group("hashtag") # send hashtag signal parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def post_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: # notify user user_regex = r'@(?P<username>[\w.\@+-]+)' usernames = re.findall(user_regex, instance.content) # usernames=match.group("username") print(usernames) #hashtag signal hashtag_regex = r'@(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hashtag_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags) # hashtags=h_match.group("hashtag") print(hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: #if tweet is created and has no parent tweet # notify a user user_regex = r'@(?P<username>[\w.@+-]+)' #python regular expression function for usernames usernames = re.findall( user_regex, instance.content ) #findall() matches all the strings in a tweet and returns username as a list of string # send notification to user here. # send hashtag signal to user here. hash_regex = r'#(?P<hashtag>[\w\d-]+)' #python regular expression function for hashtags hashtags = re.findall( hash_regex, instance.content ) #findall() matches all the strings in a tweet and return hashtag as a list of string parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def tweet_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: # alert(); user_regex = r'@(?P<username>[\w.@+-]+)' m = re.search(user_regex, instance.content) if m: username = m.group("username") # alert(); print(username) hash_regex = r'#(?P<hashtag>[\w\d-]+)' h_m = re.search(hash_regex, instance.content) if h_m: hashtag = h_m.group("hashtag") parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtag) print(hashtag)
def question_save_receiver(sender, instance, created, *args, **kwargs): if created and not instance.parent: hash_regex = r'#(?P<username>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.content) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)
def create_hashtags(sender, instance, created, **kwargs): if created: hash_regex = r'#(?P<hashtag>[\w\d-]+)' hashtags = re.findall(hash_regex, instance.text) parsed_hashtags.send(sender=instance.__class__, hashtag_list=hashtags)