# HG changeset patch # User Daniel Poelzleithner # Date 1286305001 -7200 # Node ID de6b80867eb771289023ab8c30c0bedc810a9879 # Parent fa55c8ded9fd55c8239f02629929d12eca0bb91e make user names clickable simplify pseudonym code by having one place to generate ui.field.text diff -r fa55c8ded9fd -r de6b80867eb7 app/main/draft/_list.lua --- a/app/main/draft/_list.lua Tue Oct 05 16:18:39 2010 +0200 +++ b/app/main/draft/_list.lua Tue Oct 05 20:56:41 2010 +0200 @@ -15,10 +15,8 @@ { label = _"Author", content = function(record) - if app.session.member_id or config.public_access == "pseudonym" then - ui.field.text{ readonly = true, value = record.author.name } - else - ui.field.text{ readonly = true, value = _"[not displayed public]" } + if record.author then + return record.author:ui_field_text() end end }, diff -r fa55c8ded9fd -r de6b80867eb7 app/main/draft/_show.lua --- a/app/main/draft/_show.lua Tue Oct 05 16:18:39 2010 +0200 +++ b/app/main/draft/_show.lua Tue Oct 05 20:56:41 2010 +0200 @@ -7,15 +7,30 @@ content = function() if app.session.member_id or config.public_access == "pseudonym" then - ui.field.text{ - label = _"Last author", - value = _( - "#{author} at #{date}", { - author = draft.author_name, - date = format.timestamp(draft.created) - } - ) - } + if draft.author then + -- ugly workaround for getting html into a replaced string und to the user + ui.container{label = _"Last author", label_attr={class="ui_field_label"}, content = function() + local str = _("#{author} at #{date}", + {author = string.format('%s', + encode.url{ + module = "member", + view = "show", + id = draft.author.id, + }, + encode.html(draft.author.name)), + date = encode.html(format.timestamp(draft.created)) + } + ) + slot.put("", str, "") + end + } + else + text = _("#{author} at #{date}", { + author = encode.html(draft.author_name), + date = format.timestamp(draft.created) + }) + ui.field.text{label = _"Last author", value = text } + end else ui.field.text{ label = _"Last author", diff -r fa55c8ded9fd -r de6b80867eb7 app/main/opinion/_list.lua --- a/app/main/opinion/_list.lua Tue Oct 05 16:18:39 2010 +0200 +++ b/app/main/opinion/_list.lua Tue Oct 05 20:56:41 2010 +0200 @@ -5,7 +5,7 @@ columns = { { label = _"Member name", - name = "member_name" + content = function(arg) return Member.object.ui_field_text(arg.member) end }, { label = _"Degree", diff -r fa55c8ded9fd -r de6b80867eb7 app/main/suggestion/_opinions.lua --- a/app/main/suggestion/_opinions.lua Tue Oct 05 16:18:39 2010 +0200 +++ b/app/main/suggestion/_opinions.lua Tue Oct 05 20:56:41 2010 +0200 @@ -5,7 +5,6 @@ view = "_list", params = { opinions_selector = Opinion:new_selector() - :add_field("member.name", "member_name") :add_where{ "suggestion_id = ?", suggestion.id } :join("member", nil, "member.id = opinion.member_id") :add_order_by("member.id DESC") diff -r fa55c8ded9fd -r de6b80867eb7 app/main/suggestion/_suggestion.lua --- a/app/main/suggestion/_suggestion.lua Tue Oct 05 16:18:39 2010 +0200 +++ b/app/main/suggestion/_suggestion.lua Tue Oct 05 20:56:41 2010 +0200 @@ -5,10 +5,8 @@ record = suggestion, readonly = true, content = function() - if app.session.member_id or config.public_access == "pseudonym" then - ui.field.text{ label = _"Author", value = suggestion.author.name } - else - ui.field.text{ label = _"Author", value = _"[not displayed public]" } + if suggestion.author then + suggestion.author:ui_field_text{label=_"Author"} end ui.field.text{ label = _"Title", name = "name" } ui.container{ diff -r fa55c8ded9fd -r de6b80867eb7 model/member.lua --- a/model/member.lua Tue Oct 05 16:18:39 2010 +0200 +++ b/model/member.lua Tue Oct 05 20:56:41 2010 +0200 @@ -367,4 +367,23 @@ :add_where("notify_email_lock_expiry > now()") :count() == 1 ) -end \ No newline at end of file +end + +function Member.object:ui_field_text(args) + args = args or {} + if app.session.member_id or config.public_access == "pseudonym" then + -- ugly workaround for getting html into a replaced string and to the user + ui.container{label = args.label, label_attr={class="ui_field_label"}, content = function() + slot.put(string.format('%s', + encode.url{ + module = "member", + view = "show", + id = self.id, + }, + encode.html(self.name))) + end + } + else + ui.field.text{ label = args.label, value = _"[not displayed public]" } + end +end