Auction: categories

master
E. Almqvist 3 years ago
parent 1e4cc231e3
commit b9992292ae
  1. 5
      src/db_models.rb
  2. 11
      src/views/auction/new.slim
  3. 4
      src/views/auction/view.slim

@ -341,6 +341,11 @@ class Auction < EntityModel
def images
Image.get_relation @id
end
def categories
data = Auction_Category_relation.get "category_id", "auction_id = ?", @id
data && data.map! { |category| Category.find_by_id category["category_id"]}
end
end

@ -17,10 +17,11 @@
label Description
textarea name="description" cols="20" rows="5" title="Content length must be between #{MIN_DESC_LEN} and #{MAX_DESC_LEN} characters" pattern="#{DESC_REGEX_STR}" maxlength="#{MAX_DESC_LEN}" placeholder="Tell us about what you're selling!"
label Categories
- Category.get_all.each do |category|
.checkbox-container
input type="checkbox" name="category-#{category.id}" value="#{category.id}"
label style="color: #{category.color};" = "#{category.name}"
- if Category.get_all.length > 0
label Categories
- Category.get_all.each do |category|
.checkbox-container
input type="checkbox" name="category-#{category.id}" value="#{category.id}"
label style="color: #{category.color};" = "#{category.name}"
input type="submit" value="Post"

@ -1,5 +1,9 @@
h1 = auction.title
h2 = auction.description
ul.list-container
- auction.categories.each do |category|
p = category.name
- auction.images.each do |img|
img src="#{img.url}"

Loading…
Cancel
Save