Sha256: 5893c71aaed6af73bc221f089c8aed58c716678b7fac1d0a9d605c44a7425510
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
module PostStatus def list_status(str) case str when 'approved' then { text: generate_status(str), klass: 'tag tag-green' } when 'repost' then { text: generate_status(str), klass: 'tag tag-blue' } when 'newpost' then { text: generate_status(str), klass: 'tag tag-blue' } when 'rejected' then { text: generate_status(str), klass: 'tag tag-red' } when 'published' then { text: generate_status(str), klass: 'tag tag-green' } when 'reviewing' then { text: generate_status(str), klass: 'tag tag-yellow' } when 'draft' then { text: generate_status(str), klass: 'tag tag-gray' } when 'need_review' then { text: generate_status(str), klass: 'tag tag-yellow' } when 'unvailable' then { text: generate_status(str), klass: 'tag tag-gray' } when 'waiting' then { text: generate_status(str), klass: 'tag tag-red' } end end def status_view_editor(post) status = post.status status = 'newpost' if status == 'reviewing' && post.count_submit <= 1 status = 'repost' if status == 'reviewing' && post.count_submit > 1 status = 'unvailable' if status.nil? generate_span_status(status) end def status_view_translator(status) status = 'waiting' if status.nil? generate_span_status(status) end def status_view_writer(post) status = post.status status = 'approved' if status == 'need_review' generate_span_status(status) end private def generate_span_status(status) text = list_status(status).fetch(:text) klass = list_status(status).fetch(:klass) content_tag(:span, text, class: klass) end def generate_status(str) I18n.t(".post_status.status.#{str}") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wakuwaku_module-0.1.3 | lib/wakuwaku_module/post_status.rb |
wakuwaku_module-0.1.2 | lib/wakuwaku_module/post_status.rb |