Skip to content

Commit

Permalink
fixing #96
Browse files Browse the repository at this point in the history
  • Loading branch information
TangentFoxy committed Oct 17, 2016
1 parent 8d976a4 commit e323ae4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 7 additions & 13 deletions ksp.moon
Expand Up @@ -84,12 +84,14 @@ class extends lapis.Application
input type: "submit"

POST: =>
local status
local status, user_id
if @session.id
if (Users\find id: @session.id).admin -- if an admin is uploading, it is imported
status = Crafts.statuses.imported
user_id = 0
else -- else give it the user's name
@params.creator_name = (Users\find id: @session.id).name
user_id = @session.id
if @params.picture\len! > 0
if @params.picture\sub(1, 7) == "http://"
@params.picture = "https://#{@params.picture\sub 8}"
Expand All @@ -108,12 +110,6 @@ class extends lapis.Application
@session.info = "Craft submission failed: Craft link is invalid."
return redirect_to: @url_for "ksp_submit_crafts"

local user_id
if @session.id
user_id = @session.id
else
user_id = 1

craft, errMsg = Crafts\create {
craft_name: @params.craft_name
download_link: @params.download_link
Expand Down Expand Up @@ -187,7 +183,7 @@ class extends lapis.Application
tr ->
td style: "width:20%; word-wrap: break-word;", ->
a href: @url_for("ksp_craft", id: craft.id), craft.craft_name
if craft.user_id != 1
if craft.user_id != 0
td style: "width:20%; word-wrap: break-word;", (Users\find id: craft.user_id).name
else
td style: "width:20%; word-wrap: break-word;", craft.creator_name
Expand All @@ -214,7 +210,7 @@ class extends lapis.Application
GET: =>
--TODO we need a "back" button or something similar
if craft = Crafts\find id: @params.id
if craft.user_id != 1
if craft.user_id != 0
craft.creator_name = (Users\find id: craft.user_id).name
if craft.creator_name\len! > 0
@title = "#{craft.craft_name} by #{craft.creator_name}"
Expand Down Expand Up @@ -249,14 +245,12 @@ class extends lapis.Application
pre style: "white-space: pre-wrap;", craft.action_groups
p "Mods Used:"
pre style: "white-space: pre-wrap;", craft.mods_used
hr!
p "Notes from Guard13007: " .. craft.notes

if @session.id
user = Users\find id: @session.id

if @session.id == craft.user_id
hr!
p "Notes from Guard13007: " .. craft.notes

if @session.id == craft.user_id or user.admin
hr!
form {
Expand Down
6 changes: 6 additions & 0 deletions migrations.moon
Expand Up @@ -122,4 +122,10 @@ import create_table, types, drop_table, add_column, rename_column from require "
add_column "colors", "name", types.text unique: true
[16]: =>
drop_table "colors"
[17]: =>
db.update "crafts", {
user_id: 0 --what to change
}, {
user_id: 1 --matching what
}
}

0 comments on commit e323ae4

Please sign in to comment.