I want to hide some section of interface from my django application. For example if I have a widget that shows some stats I don't want this widget to be appear on every user after they login to the site. I want to hide randomly. In addition lets say if I have an search results sorting function, I want randomly pick group of users to sort it in descending order by time and other group to see it ascending order.
My first task is how to pick users randomly after they login. How do you define this type of randomness in django application. I cann't really think what example I should include here but, this is a simple widget that I have to show top 5 contributors of the site.
{% cache 600 "contributors" contributors search_tags scope sort query context.page language_code %}
<div id="contrib-users" class="box">
<h2 class="contributorback">{% trans %}Top 5 Contributors{% endtrans %}</h2>
{% spaceless %}
{% for user in contributors %}
<div class="contributor">
<div class="contrib-thumb">{{ macros.gravatar(user, 32) }}</div>
<div class="contrib-text">
<span class="contrib-username">
<a href="{{ user.get_absolute_url() }}">{{user.username|escape}}</a>
</span>
<span class="contrib-rep">{{ macros.user_score_and_badge_summary(user, settings.KARMA_MODE, settings.BADGES_MODE) }}
</div>
</div>
{% endfor %}
{% endspaceless %}
</div>
{% endcache %}
Lets assume I have users from user0001
- user1000
in the system and I want randomly pick 25%
users to see the widget. How can I accomplish that.