Sha256: 4c1cb27d368d1a6505212007f5890f81d61eeb7df6a88ad363d8227cb80075e6
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
module WakuwakuModule 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wakuwaku_module-0.1.4 | lib/wakuwaku_module/post_status.rb |