modify project package

dev_aliyun
p31729568 6 years ago
parent c442751ab0
commit bfb796d04b

@ -8,6 +8,7 @@ module Mobile
expose :title
expose :content
expose :category
expose :category_name
expose :category_id do |p, _|
p.project_package_category_id
end

@ -3,8 +3,6 @@ class ProjectPackage < ActiveRecord::Base
acts_as_attachable
CATEGORY_VALUES = %w(front backend mobile database cloud_compute_and_big_data devops_and_test ai other)
attr_accessible :title, :content, :project_package_category_id, :deadline_at, :contact_name, :contact_phone, :min_price, :max_price
belongs_to :creator, class_name: 'User'
@ -60,6 +58,10 @@ class ProjectPackage < ActiveRecord::Base
project_package_category.name
end
def category_name
project_package_category.en_name
end
def visitable?
!editable?
end
@ -91,7 +93,7 @@ class ProjectPackage < ActiveRecord::Base
end
def category_text
I18n.t("project_package.category.#{category}")
I18n.t("project_package.category.#{category_name}")
end
def status_text

@ -1,5 +1,20 @@
class ProjectPackageCategory < ActiveRecord::Base
default_scope order: 'position asc'
EN_NAMES_MAP = {
1 => 'front',
2 => 'backend',
3 => 'mobile',
4 => 'database',
5 => 'cloud_compute_and_big_data',
6 => 'devops_and_test',
7 => 'ai',
8 => 'other'
}
has_many :project_packages, dependent: :destroy
def en_name
EN_NAMES_MAP[id]
end
end

@ -1,3 +1,8 @@
<%
image_name_map = {
"前端开发" => 'front',
}
%>
<% if @type == 'p_package' && User.current == @user %>
<div class="edu-back-white padding20-30 clearfix secondNav educontent bor-top-greyE">
<li class="<%= @p == 'a' ? 'active' : '' %>"><%= link_to "全部", user_path(@user, :type => @type), :remote => true %></li>
@ -26,7 +31,7 @@
<% can_manage = @type == 'p_package' && (admin_or_business? || current_user.id == @user.id) %>
<div class="project-package-item <%= can_manage ? 'with-operator' : '' %> project-package-<%= object.id %>">
<div class="item-image">
<%= image_tag("educoder/project_packages/#{object.category}.png") %>
<%= image_tag("educoder/project_packages/#{object.category_name}.png") %>
</div>
<div class="item-body">
<div class="item-head">
@ -49,7 +54,7 @@
</div>
</div>
<div class="item-category">
<div class="item-category-item"><%= object.category_text %></div>
<div class="item-category-item"><%= object.category %></div>
</div>
<div class="item-other">
<div class="item-group item-other-visit">

Loading…
Cancel
Save