diff --git a/src/app.rb b/src/app.rb index 7da1afd..fcafbe8 100755 --- a/src/app.rb +++ b/src/app.rb @@ -173,8 +173,13 @@ post "/auctions" do newid, resp = Auction.create user_id, title, description, init_price, delta_time, category_choices - flash[:success] = "Auction posted!" - redirect "/auctions/#{newid}" + if newid then + flash[:success] = "Auction posted!" + redirect "/auctions/#{newid}" + else + flash[:error] = resp + redirect "/auctions/new" + end end get "/auctions/:id" do diff --git a/src/db_models.rb b/src/db_models.rb index dd9a6f4..8f78e76 100644 --- a/src/db_models.rb +++ b/src/db_models.rb @@ -215,7 +215,7 @@ class Auction < EntityModel # Validate the input check, errorstr = self.validate_ah(title, description, init_price, delta_time) - return errorstr unless check + return check, errorstr unless check # Get current UNIX time start_time = Time.now.to_i diff --git a/src/views/layout.slim b/src/views/layout.slim index b13b664..0749766 100644 --- a/src/views/layout.slim +++ b/src/views/layout.slim @@ -29,7 +29,7 @@ html lang="en" a.inlbutton href="/profile" target="_self" img.avatar src="#{session_user.avatar}" alt="Profile" .content-container - .flash + div class="flash" onclick="this.remove();" - flash.each do |k, v| div class="flash-#{k}" | #{v} diff --git a/src/views/stylesheets/style.sass b/src/views/stylesheets/style.sass index b8bca33..9e58b62 100644 --- a/src/views/stylesheets/style.sass +++ b/src/views/stylesheets/style.sass @@ -142,12 +142,15 @@ a.button:hover background-color: $special_clr .flash - position: absolute + position: fixed text-align: center - top: 5rem + top: 4rem + left: .8rem font-size: 1rem font-weight: bold animation: flash .2s ease-in alternate + background: $bg_alt_clr + transition: .4s opacity &-error color: $fg_error @@ -161,6 +164,10 @@ a.button:hover border: $border_size solid $green_clr border-radius: $border_radius +.flash:hover + cursor: pointer + opacity: .5 + img.avatar, img.avatar_big background: $bg_clr width: 2.25rem