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
"""
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):
# 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
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():
# 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):
--- /dev/null
+<%inherit file="/base.mako" />
+
+<h1>View Art</h1>
+
+<img src="${c.art.get_path()}"
\ No newline at end of file
</head>
<body>
<div id="header">
+<a href="${h.url_for("/")}">Home</a>
+
<div id="user">
% if c.user:
<p>Logged in as ${c.user.name}</p>
</form>
% endif
</div>
+
+
</div>
<div id="body">
${next.body()}
<%inherit file="base.mako" />
+<a href="${h.url_for(controller="art", action="new")}">Add New Art!</a>
+
<ul class="artwork-grid">
% for artwork in c.artwork:
- <li><img width="180" src="${artwork.get_path()}"</li>
+ <li><a href="${h.url_for(controller="art", action="show", id=artwork.id)}">
+ <img width="180" src="${artwork.get_path()}">
+ </a></li>
% endfor
</ul>
# 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)