Mercurial > agora
comparison apps/snippet/views.py @ 207:d534881629ff
Updated snippet's template and views files to fix rating code collision which prevented posting new snippets.
Updated snippet's models file so that now secret id of each snippet will be unique. It also means that the no two or more than two snippets will have same secret id.
author | Ahsan Ali Shahid <ahsan.ali.shahid@gmail.com> |
---|---|
date | Mon, 19 Aug 2013 20:30:19 +0500 |
parents | 499e5f47f278 |
children |
comparison
equal
deleted
inserted
replaced
206:1f1e867cb37f | 207:d534881629ff |
---|---|
106 default_pygments_style = request.user.get_profile().pygments_style | 106 default_pygments_style = request.user.get_profile().pygments_style |
107 else: | 107 else: |
108 default_pygments_style = PygmentsStyle.objects.get(pk=1) | 108 default_pygments_style = PygmentsStyle.objects.get(pk=1) |
109 | 109 |
110 | 110 |
111 | 111 r = snippet.rating.votes |
112 score = (snippet.rating.score/snippet.rating.votes) | 112 if snippet.rating.votes == 0: |
113 | 113 r = 1 |
114 | |
115 score = snippet.rating.score/(r) | |
114 | 116 |
115 context = { | 117 context = { |
116 'snippet_form': snippet_form, | 118 'snippet_form': snippet_form, |
117 'snippet': snippet, | 119 'snippet': snippet, |
118 'lines': range(snippet.get_linecount()), | 120 'lines': range(snippet.get_linecount()), |