Hello,

I'm running a test instance of OSQA, and I noticed that a lot of the recent activity in some of my users are filled with log in events. I feel that log in events are irrelevant to the recent activity of a user. What file would I edit so log in events are no longer displayed in the recent activity list?

Thanks!

asked 08 Aug '11, 00:28

tractor's gravatar image

tractor
15661316
accept rate: 0%

edited 08 Aug '11, 04:14


Hey guys, I came up with a workaround to solve this issue. Basically I created a custom template filter (filter_recent_activity) and give it as input the describe variable in activity.html:

{% load extra_tags %}
{% load humanize %}
{% load extra_tags %}
{% load filter_recent_activity %}

{% if describe|valid_activity %}
<div class="action_container">
    <div class="action_body">
        {{ describe }}
    </div>
    <div class="action_date" style="text-align: right;">
        {% diff_date action.action_date  %}
    </div>
</div>
{% endif %}

With some simple text processing I was able to determine what activity was listed (below is the code for my custom template filter (which was added to the templatetags folder with filename filter_recent_activity.py)):

from django import template
from django.template.defaultfilters import stringfilter

register = template.Library()

@register.filter @stringfilter def valid_activity(full_activity_statement):

    fas = str(full_activity_statement)

    loc01   = fas.find('&lt;/a&gt;') + 4
    chunk01 = fas[loc01:]
    loc02   = chunk01.find('&lt;a')
    if loc02 == -1:
            chunk02 = chunk01
    else:
            chunk02 = chunk01[:loc02]

    if 'logged' in chunk02:
            activity = False
    elif 'deleted' in chunk02:
            activity = False
    else:
            activity = True

    return activity

Basically, the describe variable is broken down to remove links and question titles. In essence, all you are left with is the core of the activity (i.e. logged on, edited, awarded badge, etc.), and using simple if or statements you can prevent certain activities from showing.

  • I do understand that this is inefficient since it adds a layer of code to deal with a problem that should be solved instead by taking away some code. On this note, I ask to someone who might have a feel for this kind of stuff, how much more inefficient did I make the code?

link

answered 08 Aug '11, 04:09

tractor's gravatar image

tractor
15661316
accept rate: 0%

edited 08 Aug '11, 12:46

You can include code in text form by indenting it 4 spaces, this would make it easier to copy than an image...

(08 Aug '11, 05:57) Rich Seller

Hey I changed the pictures to text, if you want to try it out, check out the edit.

(08 Aug '11, 12:43) tractor
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×44
×4
×2

Asked: 08 Aug '11, 00:28

Seen: 401 times

Last updated: 08 Aug '11, 12:46

powered by OSQA