Cambiado user por tag, que es más correcto
authorDaniel Garcia <dgarcia@yaco.es>
Wed, 24 Feb 2010 10:14:36 +0000 (11:14 +0100)
committerDaniel Garcia <dgarcia@yaco.es>
Wed, 24 Feb 2010 10:14:36 +0000 (11:14 +0100)
proposal/app.py
proposal/db.py
proposal/templates/proposal.html
proposal/view/prop.py

index a05d9c7..182d071 100755 (executable)
@@ -14,7 +14,7 @@ urls = (
         '/vote/(\d+)/(\-?1).ajax', 'view.prop.VoteAjax',
         '/vote/(\d+)/(\-?1)', 'view.prop.Vote',
         '/comment/(\d+)', 'view.prop.Comment',
-        '/view/user/(\w+)', 'view.prop.ViewUser',
+        '/view/tag/(\w+)', 'view.prop.ViewTag',
         '/view/(\d+)', 'view.prop.View',
         '/new', 'view.prop.New',
         '.*', 'view.prop.New',
index abad943..7212b17 100644 (file)
@@ -10,13 +10,13 @@ Base = declarative_base()
 metadata = Base.metadata
 
 
-class User(Base):
-    __tablename__ = 'users'
+class Tag(Base):
+    __tablename__ = 'tags'
 
     name = Column(String(60), primary_key=True)
 
     def __unicode__(self):
-        return '<User "%s">' % self.name
+        return '<Tag "%s">' % self.name
 
 
 class Proposal(Base):
@@ -27,11 +27,11 @@ class Proposal(Base):
     desc = Column(String)
     votes = Column(Integer)
 
-    users_proposals = Table('users_proposals', metadata,
-            Column('user_id', String, ForeignKey('users.name')),
+    tags_proposals = Table('tags_proposals', metadata,
+            Column('tag_id', String, ForeignKey('tags.name')),
             Column('proposal_id', Integer, ForeignKey('proposals.id')))
 
-    users = relation('User', secondary=users_proposals, backref='proposals')
+    tags = relation('Tag', secondary=tags_proposals, backref='proposals')
 
 
 class Comment(Base):
index 8b427c5..bdc08eb 100644 (file)
@@ -17,11 +17,11 @@ $def with (proposals, trim=False)
                 ...
         $else:
             $:markdown(proposal.desc)
-        <div class="prop_users">
-            $for user in proposal.users:
-                <a href="/view/user/$user.name">$user.name</a>
+        <div class="prop_tags">
+            $for tag in proposal.tags:
+                <a href="/view/tag/$tag.name">$tag.name</a>
                 $if not loop.last:
-                    , 
+                    ,
         </div>
 
         $if not trim:
index e91c2eb..eced352 100644 (file)
@@ -37,14 +37,14 @@ class New:
 
         name = prop_form.d.name
         desc = prop_form.d.desc
-        user_names = name_regexp.findall(desc)
+        tags_names = name_regexp.findall(desc)
 
-        users = orm.query(db.User).filter(db.User.name.in_(user_names)).all()
-        user_queries = [i.name for i in users]
-        users += [db.User(name=u) for u in user_names if not u in user_queries]
+        tags = orm.query(db.Tag).filter(db.Tag.name.in_(tags_names)).all()
+        tag_queries = [i.name for i in tags]
+        tags += [db.Tag(name=u) for u in tags_names if not u in tag_queries]
 
         prop = db.Proposal(name=name, desc=desc, votes=0)
-        prop.users = users
+        prop.tags = tags
         orm.add(prop)
 
         raise web.seeother('/')
@@ -60,14 +60,14 @@ class View:
         return render.view([prop])
 
 
-class ViewUser:
-    def GET(self, username):
+class ViewTag:
+    def GET(self, name):
         orm = web.ctx.orm
         render = web.ctx.render
 
         def propcmp(x, y):
-            return cmp(x.votes, y.votes) 
-        prop = sorted(orm.query(db.User).get(username).proposals,
+            return cmp(x.votes, y.votes)
+        prop = sorted(orm.query(db.Tag).get(name).proposals,
                                 propcmp, reverse=True)
 
         return render.view(prop)