def update_question_view_times(request, question): last_seen_in_question = request.session.get('last_seen_in_question', {}) last_seen = last_seen_in_question.get(question.id, None) if (not last_seen) or (last_seen < question.last_activity_at): QuestionViewAction(question, request.user, ip=request.META['REMOTE_ADDR']).save() last_seen_in_question[question.id] = datetime.datetime.now() request.session['last_seen_in_question'] = last_seen_in_question
def update_question_view_times(request, question): if not 'last_seen_in_question' in request.session: request.session['last_seen_in_question'] = {} last_seen = request.session['last_seen_in_question'].get(question.id, None) if (not last_seen) or last_seen < question.last_activity_at: QuestionViewAction(question, request.user, ip=request.META['REMOTE_ADDR']).save() request.session['last_seen_in_question'][question.id] = datetime.datetime.now() request.session['last_seen_in_question'][question.id] = datetime.datetime.now()
def update_question_view_times(request, question): last_seen_in_question = request.session.get('last_seen_in_question', {}) last_seen = last_seen_in_question.get(question.id, None) #TODO: remove temp fix if question.last_activity_at is None: question.update_last_activity(question.author, save=True, time=question.added_at) if (not last_seen) or (last_seen < question.last_activity_at): QuestionViewAction(question, request.user, ip=request.META['REMOTE_ADDR']).save() last_seen_in_question[question.id] = datetime.datetime.now() request.session['last_seen_in_question'] = last_seen_in_question
def update_question_view_times(request, question): last_seen_in_question = request.session.get('last_seen_in_question', {}) last_seen = last_seen_in_question.get(question.id, None) if (not last_seen) or (last_seen < question.last_activity_at): try: QuestionViewAction(question, request.user, ip=request.META['REMOTE_ADDR']).save() except Exception, e: import traceback logging.error( "Caught exception %s in update_question_view_times :\n %s" % (str(e), traceback.format_exc())) last_seen_in_question[question.id] = datetime.datetime.now() request.session['last_seen_in_question'] = last_seen_in_question
if not action.viewuser.is_authenticated(): return try: subscription = QuestionSubscription.objects.get(question=action.node, user=action.viewuser) subscription.last_view = datetime.datetime.now() subscription.save() except: if action.viewuser.subscription_settings.questions_viewed: subscription = QuestionSubscription(question=action.node, user=action.viewuser) subscription.save() QuestionViewAction.hook(question_viewed) #todo: translate this #record_answer_event_re = re.compile("You have received (a|\d+) .*new response.*") #def record_answer_event(instance, created, **kwargs): # if created: # q_author = instance.question.author # found_match = False # #print 'going through %d messages' % q_author.message_set.all().count() # for m in q_author.message_set.all(): ## #print m.message # # match = record_answer_event_re.search(m.message) # if match: # found_match = True # try: # cnt = int(match.group(1))
UserJoinsAction.hook(member_joined) def question_viewed(action, new): if not action.viewuser.is_authenticated(): return try: subscription = QuestionSubscription.objects.get(question=action.node, user=action.viewuser) subscription.last_view = datetime.datetime.now() subscription.save() except: if action.viewuser.subscription_settings.questions_viewed: subscription = QuestionSubscription(question=action.node, user=action.viewuser) subscription.save() QuestionViewAction.hook(question_viewed) #todo: translate this #record_answer_event_re = re.compile("You have received (a|\d+) .*new response.*") #def record_answer_event(instance, created, **kwargs): # if created: # q_author = instance.question.author # found_match = False # #print 'going through %d messages' % q_author.message_set.all().count() # for m in q_author.message_set.all(): ## #print m.message # # match = record_answer_event_re.search(m.message) # if match: # found_match = True # try: