Skip to content

Commit

Permalink
fixed the 'my stumps' issue. Index view now, by default, will show al…
Browse files Browse the repository at this point in the history
…l stumps submitted by the currently logged in user near the bottom of the page. If you aren't logged in (you can't submit a stump then anyway), you will only see the recent and top visited ones as before.
  • Loading branch information
mutaku committed Jun 2, 2011
1 parent ca1cfc6 commit 57e4d24
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions shortener/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
import bleach

def index(request):
# my_stumps = ""
# if request.user.is_authenticated():
# my_stumps = stump.objects.get(cookie=smart_str(request.user)).order_by('-id')
my_stumps = ""
if request.user.is_authenticated():
my_stumps = stump.objects.filter(cookie__iexact=request.user).order_by('-id')
stumpy_domain = smart_str(Site.objects.get_current().domain)
stump_stats_num = stump.objects.all().count()
stump_stats_visits = stump.objects.aggregate(Sum('hits'))['%s__sum' % 'hits']
recent_stumps_list = stump.objects.all().order_by('-id')[:5]
famous_stumps_list = stump.objects.all().order_by('-hits')[:5]
return render_to_response('stumpy/index.html', {
'stumpy_domain': stumpy_domain,
# 'my_stumps': my_stumps,
'my_stumps': my_stumps,
'recent_stumps_list': recent_stumps_list,
'famous_stumps_list': famous_stumps_list,
'stump_stats_num': stump_stats_num,
Expand All @@ -43,16 +43,11 @@ def submit(request,stumpurl):
stumpy_domain = smart_str(Site.objects.get_current().domain)
stump_clean = bleach.clean(stumpurl)
this_stump = smart_str(stump_clean)
############################################################
############################################################
# This code portion is temporary hack for // -> /
# it will be removed once I have it fixed legit
# This code portion is temporary hack for // -> / .... this is a wsgi issue
stump_split = list(this_stump.partition(":"))
if stump_split[1] and stump_split[2].startswith("/"):
stump_split[2] = "/"+stump_split[2]
this_stump = ''.join(stump_split)
############################################################
############################################################
this_hash = hashlib.sha1(this_stump).hexdigest()
does_exist = stump.objects.filter(hashurl=this_hash)
if not does_exist:
Expand Down

1 comment on commit 57e4d24

@mutaku
Copy link
Owner Author

@mutaku mutaku commented on 57e4d24 Jun 2, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #33

Please sign in to comment.