On 6 Aug 2009, at 20:42, NoSyu wrote:
>
> Hello
>
> I see this problem few weeks ago.
>
> So maybe someone find it and make a ticket.
>
> I can't find ticket, so I write problems and solution in this article.
>
>
> Here is the original source Sage 4.1 server/notebook/twist.py line
> 1266~1299
>
> class Worksheet_rating_info(WorksheetResource, resource.Resource):
> def render(self, ctx):
> s = self.worksheet.html_ratings_info()
> return HTMLResponse(stream=message('''
> <h2 align=center>Ratings for %s</h2>
> <h3 align=center><a href='/home/%s'>Go to the worksheet.</a>
> <br><br>
> <table width=70%%align=center border=1 cellpadding=10
> cellspacing=0>
> <tr bgcolor="#7799bb"><td width=30em>User</td><td width=10em
> align=center>Rating</td><td width=10em align=center
> width=60em>Comment</td></tr>
> %s
> </table>
> <br><br>
> '''%(self.worksheet.name(), self.worksheet.filename(), s)))
>
>
> class Worksheet_rate(WorksheetResource, resource.Resource):
> def render(self, ctx):
> ret = '/home/' + self.worksheet.filename()
> #if self.worksheet.is_rater(self.username):
> # return HTMLResponse(stream=message("You have already
> rated the worksheet <i><b>%s</b></i>."%self.worksheet.name(), ret))
> if user_type(self.username) == "guest":
> return HTMLResponse(stream = message(
> 'You must <a href="/">login first</a> in order to rate
> this worksheet.', ret))
>
> rating = int(ctx.args['rating'][0])
> if rating < 0 or rating >= 5:
> return HTMLResponse(stream = message(
> "Gees -- You can't fool the rating system that
> easily!", ret))
> comment = ctx.args['comment'][0]
> self.worksheet.rate(rating, comment, self.username)
> return HTMLResponse(stream=message("""
> Thank you for rating the worksheet <b><i>%s</i></b>!
> You can <a href="rating_info">see all ratings of this
> worksheet.</a>
> """%self.worksheet.name(), '/pub/'))
>
>
> and here is fixed soruce.
>
> class Worksheet_rating_info(WorksheetResource, resource.Resource):
> def render(self, ctx):
> s = self.worksheet.html_ratings_info()
> return HTMLResponse(stream='''
> <h2 align=center>Ratings for %s</h2>
> <h3 align=center><a href='/home/%s'>Go to the worksheet.</a>
> <br><br>
> <table width=70%%align=center border=1 cellpadding=10
> cellspacing=0>
> <tr bgcolor="#7799bb"><td width=30em>User</td><td width=10em
> align=center>Rating</td><td width=10em align=center
> width=60em>Comment</td></tr>
> %s
> </table>
> <br><br>
> '''%(self.worksheet.name(), self.worksheet.filename(), s))
>
>
> class Worksheet_rate(WorksheetResource, resource.Resource):
> def render(self, ctx):
> ret = '/home/' + self.worksheet.filename()
> #if self.worksheet.is_rater(self.username):
> # return HTMLResponse(stream=message("You have already
> rated the worksheet <i><b>%s</b></i>."%self.worksheet.name(), ret))
> if user_type(self.username) == "guest":
> return HTMLResponse(stream = message(
> 'You must <a href="/">login first</a> in order to rate
> this worksheet.', ret))
>
> rating = int(ctx.args['rating'][0])
> if rating < 0 or rating >= 5:
> return HTMLResponse(stream = message(
> "Gees -- You can't fool the rating system that
> easily!", ret))
> comment = ctx.args['comment'][0]
> self.worksheet.rate(rating, comment, self.username)
> return HTMLResponse(stream="""
> Thank you for rating the worksheet <b><i>%s</i></b>!
> You can <a href="rating_info">see all ratings of this
> worksheet.</a>
> """%self.worksheet.name())
>
>
> The problem is that if the right result, it use message function.
>
> message function is like this.
>
> ############################
> # An error message
> ############################
> def message(msg, cont=None):
> template_dict = {'msg': msg, 'cont': cont}
> return template('error_message.html', **template_dict)
>
> It use for error page. But original source use it to show right result
> such as rate and raing_info page.
>
> Can I make a ticket for this?
I tried this proposed fix on sage-4.1, and it did not change the
result I get if clicking on the rating_info link for an unrated
worksheet.
--
Kevin Horton
Ottawa, Canada
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---