From: Eevee Date: Thu, 8 Oct 2009 04:26:43 +0000 (-0700) Subject: Removed trailing spaces. X-Git-Url: http://git.veekun.com/zzz-floof.git/commitdiff_plain/ee952326340b2251b42db34f4823b0495338be86?hp=eba4c9b980b8a0ff0953e56975c263bf361f4684 Removed trailing spaces. --- diff --git a/floof/config/routing.py b/floof/config/routing.py index c9b4975..ffce2d6 100644 --- a/floof/config/routing.py +++ b/floof/config/routing.py @@ -52,7 +52,7 @@ def make_map(): sub.connect('create_art', '/art/create', action="create") sub.connect('rate_art', '/art/{id}/rate', action="rate") sub.connect('show_art', '/art/{id}', action="show") - + with map.submapper(controller='tag') as sub: sub.connect('delete_tag', '/art/{art_id}/tag/{id}') sub.connect('create_tag', '/art/{art_id}/tag') @@ -61,14 +61,14 @@ def make_map(): parent_resource=dict(member_name='art', collection_name='art')) # Yeah, parent resources are specified kinda dumb-ly. Would be better if you could pass in the # real parent resource instead of mocking it up with a silly dict. We should file a feature request. - + # I think resources is the right way to go for most things. It ensures all of our actions have the right # methods on them, at least. It does require the use of silly _method="delete" post parameters though. - + # One sticking point though is, it'll happily allow you to add any formatting string you want, like art/1.json # I wonder if there's a way to place requirements on that, or disable it until we actually have formats. # It just serves the same action as usual but with a format argument in the context. - + # map.connect('/art/new', controller='art', action='new') # map.connect('/art/upload', controller='art', action='upload') # map.connect('show_art', '/art/{id}', controller='art', action='show') diff --git a/floof/controllers/art.py b/floof/controllers/art.py index 5186daa..ca1d7dc 100644 --- a/floof/controllers/art.py +++ b/floof/controllers/art.py @@ -49,7 +49,7 @@ class ArtController(BaseController): if c.user: c.your_score = c.art.user_score(c.user) return render("/art/show.mako") - + # TODO: login required def rate(self, id): @@ -59,8 +59,8 @@ class ArtController(BaseController): score = int(score) else: score = Rating.reverse_options.get(score) - + c.art.rate(score, c.user) elixir.session.commit() - + redirect(url('show_art', id=c.art.id)) diff --git a/floof/controllers/search.py b/floof/controllers/search.py index 57ff4d2..4e92a6d 100644 --- a/floof/controllers/search.py +++ b/floof/controllers/search.py @@ -18,11 +18,11 @@ class SearchController(BaseController): def index(self): if request.params.get('button') == 'Save': return self.save() - + c.query = request.params.get('query', '') c.artwork = do_search(c.query) return render('/index.mako') - + # TODO: login required def save(self): c.query = request.params.get('query', '') @@ -30,19 +30,18 @@ class SearchController(BaseController): elixir.session.commit() redirect(url('saved_searches')) # TODO: do something better than this. - - + + # TODO: login required def list(self): c.searches = c.user.searches return render('/searches.mako') - + # TODO: login required def display(self, id): c.search = h.get_object_or_404(SavedSearch, id=id) c.gallery = GalleryWidget(search=c.search, page=c.user.primary_page) elixir.session.commit() redirect(url(controller="users", action="view", name=c.user.name)) - - - \ No newline at end of file + + diff --git a/floof/controllers/tag.py b/floof/controllers/tag.py index 874e605..4f98994 100644 --- a/floof/controllers/tag.py +++ b/floof/controllers/tag.py @@ -19,7 +19,7 @@ class TagController(BaseController): elixir.session.delete(tag) elixir.session.commit() redirect(url('show_art', id=art_id)) - + # TODO: login required def create(self, art_id): c.art = h.get_object_or_404(Art, id=art_id) diff --git a/floof/lib/dbhelpers.py b/floof/lib/dbhelpers.py index 0da968b..23fd3b4 100644 --- a/floof/lib/dbhelpers.py +++ b/floof/lib/dbhelpers.py @@ -3,7 +3,7 @@ def find_or_create(model, **kwargs): if not instance: instance = model(**kwargs) return instance - + def update_or_create(model, get_by, update_with): instance = model.get_by(**get_by) if instance: diff --git a/floof/model/art.py b/floof/model/art.py index b709610..1bde59b 100644 --- a/floof/model/art.py +++ b/floof/model/art.py @@ -52,7 +52,7 @@ class Art(Entity): if tag: elixir.session.delete(tag) - else: + else: if len(text) > 50: raise "Long Tag!" # can we handle this more gracefully? # sqlite seems happy to store strings much longer than the supplied limit... @@ -66,7 +66,7 @@ class Art(Entity): def rate(self, score, user): return update_or_create(Rating, {"rater":user, "art":self}, {"score":score}) - + def user_score(self, user): rating = Rating.get_by(rater=user, art=self) if rating: @@ -104,19 +104,19 @@ class TagText(Entity): def __unicode__(self): return self.text - + class Rating(Entity): art = ManyToOne('Art', ondelete='cascade') rater = ManyToOne('User', ondelete='cascade') score = Field(Integer) - + # @score.setter - # def score(self, value): - + # def score(self, value): + options = {-1:"sucks", 0:"undecided", 1:"good", 2:"great"} default = 0 # options = ["sucks","neutral","good","great"] - + Rating.reverse_options = dict (zip(Rating.options.values(), Rating.options.keys())) \ No newline at end of file diff --git a/floof/model/search.py b/floof/model/search.py index be2bb9e..01d45a2 100644 --- a/floof/model/search.py +++ b/floof/model/search.py @@ -6,10 +6,10 @@ from floof.lib.search import do_search class SavedSearch(Entity): string = Field(Unicode) # I tried calling this query, but it broke elixir author = ManyToOne('User') - + def __unicode__(self): return self.string - + @property def results(self): return do_search(self.string) @@ -23,19 +23,18 @@ class GalleryWidget(Entity): # NOTE: no longer needed now that we have pages, I guess. # displayer = ManyToOne('User') # determines whose page should it should show up on # # Could be no-ones, if it's just a template. - + # Needs some fields for position on your page @property def string(self): return self.search - + @string.setter def string(self, value): # TODO: should we delete the possibly orphaned saved search? # if not self.displayer: # # TODO: may have to refactor this into an init if the key ordering is inconvenienc # raise "Oh no! This gallery needs a displayer to set on the saved search." - + self.search = SavedSearch(author=getattr(self,"author",None), string=value) - \ No newline at end of file diff --git a/floof/model/users.py b/floof/model/users.py index 86c31d8..e2afd17 100644 --- a/floof/model/users.py +++ b/floof/model/users.py @@ -17,18 +17,18 @@ class User(Entity): pages = OneToMany('UserPage', inverse="owner") primary_page = OneToOne('UserPage', inverse="owner") - + def __unicode__(self): return self.name def __init__(self, **kwargs): super(User, self).__init__(**kwargs) - - - + + + # TODO: have this clone a standard starter page self.primary_page = UserPage(owner=self, title="default", visible=True) - + # a starter gallery, just for fun gallery = GalleryWidget(owner=self, string="awesome") self.primary_page.galleries.append(gallery) @@ -46,11 +46,11 @@ class UserPage(Entity): Page templates that provide familiar interfaces will also be UserPage records. Users will see a panel full of them, and they can choose to clone those template pages to their own page list. If more than one is set to visible, there would be tabs. - + """ - + owner = ManyToOne('User', inverse="pages") title = Field(String) - + visible = Field(Boolean) galleries = OneToMany('GalleryWidget') \ No newline at end of file diff --git a/floof/templates/base.mako b/floof/templates/base.mako index 73f069c..38226db 100644 --- a/floof/templates/base.mako +++ b/floof/templates/base.mako @@ -17,8 +17,8 @@ % endif ${h.form(h.url_for('search'), method='GET')} -${h.text('query', c.query)} -${h.submit('button', 'Search')} +${h.text('query', c.query)} +${h.submit('button', 'Search')} % if c.user: ${h.submit('button', 'Save')}