From: Nick Retallack Date: Sun, 4 Oct 2009 11:42:37 +0000 (-0700) Subject: uploaded by works, and now you can view art on its own page. X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/ef69b26ffcf9185496775bcf73384ea3a5e5691c?hp=f7617496a08f10a77eb909982dae4e995c132900 uploaded by works, and now you can view art on its own page. --- diff --git a/floof/controllers/art.py b/floof/controllers/art.py index e34543b..6ce9762 100644 --- a/floof/controllers/art.py +++ b/floof/controllers/art.py @@ -23,6 +23,10 @@ class ArtController(BaseController): def upload(self): print "PARAMS", request.params - Art(**request.params) + Art(uploaded_by=c.user, **request.params) elixir.session.commit() redirect_to(controller="main", action="index") + + def show(self, id): + c.art = Art.get(id) + return render("/art/show.mako") \ No newline at end of file diff --git a/floof/lib/file_storage.py b/floof/lib/file_storage.py index 1d1c720..0b72690 100644 --- a/floof/lib/file_storage.py +++ b/floof/lib/file_storage.py @@ -19,7 +19,7 @@ guess_type(temp.filename)[0] """ def get_path(space, hash): - return os.path.join( space, hash[:2], hash[2:] ) + return "/" + os.path.join( space, hash[:2], hash[2:] ) def save_file(space, temp): diff --git a/floof/model/art.py b/floof/model/art.py index e78de41..1df10cc 100644 --- a/floof/model/art.py +++ b/floof/model/art.py @@ -4,7 +4,7 @@ # Copyright (c) 2009 Scribblr # -from elixir import Entity, Field, Integer, Unicode +# from elixir import Entity, Field, Integer, Unicode from elixir import * from pylons import config @@ -15,13 +15,12 @@ class Art(Entity): title = Field(Unicode(120)) original_filename = Field(Unicode(120)) hash = Field(String) + uploaded_by = ManyToOne('User') def __init__(self, **kwargs): # I wanted to check for the existence of the file, but... # for some reason this FieldStorage object always conditions as falsey. self.hash = save_file("art", kwargs.pop('file')) - - super(Art, self).__init__(**kwargs) # this is what super is doing, pretty much. # for key, value in kwargs.items(): diff --git a/floof/model/users.py b/floof/model/users.py index 0f05a52..6b06048 100644 --- a/floof/model/users.py +++ b/floof/model/users.py @@ -4,10 +4,12 @@ # Copyright (c) 2009 Scribblr # -from elixir import Entity, Field, Unicode, belongs_to, has_many +# from elixir import Entity, Field, Unicode, belongs_to, has_many +from elixir import * class User(Entity): name = Field(Unicode(20)) + uploads = OneToMany('Art') has_many('identity_urls', of_kind='IdentityURL') class IdentityURL(Entity): diff --git a/floof/templates/art/show.mako b/floof/templates/art/show.mako new file mode 100644 index 0000000..7d54f98 --- /dev/null +++ b/floof/templates/art/show.mako @@ -0,0 +1,5 @@ +<%inherit file="/base.mako" /> + +

View Art

+ +
${next.body()} diff --git a/floof/templates/index.mako b/floof/templates/index.mako index 057399b..e9abdfa 100644 --- a/floof/templates/index.mako +++ b/floof/templates/index.mako @@ -1,7 +1,11 @@ <%inherit file="base.mako" /> +Add New Art! + diff --git a/floof/websetup.py b/floof/websetup.py index 7caeed0..b1611c9 100644 --- a/floof/websetup.py +++ b/floof/websetup.py @@ -18,6 +18,7 @@ def setup_app(command, conf, vars): # Initialisation here ... this sort of stuff: # Users + from floof.model.users import IdentityURL, User identity_url = IdentityURL(url=u'http://eevee.livejournal.com/') user = User(name=u'Eevee') user.identity_urls.append(identity_url)