changeset 6320:296581686f02

db: rename Gist.gist_owner to Gist.owner_id For consistency with the existing "owner" relationship.
author Søren Løvborg <sorenl@unity3d.com>
date Thu, 27 Oct 2016 18:33:42 +0200
parents f4059fe16118
children 78a4bbc24b42
files kallithea/controllers/admin/gists.py kallithea/controllers/api/api.py kallithea/model/db.py kallithea/model/gist.py kallithea/templates/admin/gists/show.html
diffstat 5 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/admin/gists.py	Mon Sep 19 14:46:12 2016 +0200
+++ b/kallithea/controllers/admin/gists.py	Thu Oct 27 18:33:42 2016 +0200
@@ -79,17 +79,17 @@
         # MY private
         if c.show_private and not c.show_public:
             gists = gists.filter(Gist.gist_type == Gist.GIST_PRIVATE) \
-                             .filter(Gist.gist_owner == c.authuser.user_id)
+                             .filter(Gist.owner_id == c.authuser.user_id)
         # MY public
         elif c.show_public and not c.show_private:
             gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC) \
-                             .filter(Gist.gist_owner == c.authuser.user_id)
+                             .filter(Gist.owner_id == c.authuser.user_id)
 
         # MY public+private
         elif c.show_private and c.show_public:
             gists = gists.filter(or_(Gist.gist_type == Gist.GIST_PUBLIC,
                                      Gist.gist_type == Gist.GIST_PRIVATE)) \
-                             .filter(Gist.gist_owner == c.authuser.user_id)
+                             .filter(Gist.owner_id == c.authuser.user_id)
 
         # default show ALL public gists
         if not c.show_public and not c.show_private:
@@ -153,7 +153,7 @@
     @NotAnonymous()
     def delete(self, gist_id):
         gist = GistModel().get_gist(gist_id)
-        owner = gist.gist_owner == c.authuser.user_id
+        owner = gist.owner_id == c.authuser.user_id
         if h.HasPermissionAny('hg.admin')() or owner:
             GistModel().delete(gist)
             Session().commit()
--- a/kallithea/controllers/api/api.py	Mon Sep 19 14:46:12 2016 +0200
+++ b/kallithea/controllers/api/api.py	Thu Oct 27 18:33:42 2016 +0200
@@ -2380,7 +2380,7 @@
         """
         gist = get_gist_or_error(gistid)
         if not HasPermissionAny('hg.admin')():
-            if gist.gist_owner != self.authuser.user_id:
+            if gist.owner_id != self.authuser.user_id:
                 raise JSONRPCError('gist `%s` does not exist' % (gistid,))
         return gist.get_api_data()
 
@@ -2408,7 +2408,7 @@
         gists = []
         _gists = Gist().query() \
             .filter(or_(Gist.gist_expires == -1, Gist.gist_expires >= time.time())) \
-            .filter(Gist.gist_owner == user_id) \
+            .filter(Gist.owner_id == user_id) \
             .order_by(Gist.created_on.desc())
         for gist in _gists:
             gists.append(gist.get_api_data())
@@ -2509,7 +2509,7 @@
         """
         gist = get_gist_or_error(gistid)
         if not HasPermissionAny('hg.admin')():
-            if gist.gist_owner != self.authuser.user_id:
+            if gist.owner_id != self.authuser.user_id:
                 raise JSONRPCError('gist `%s` does not exist' % (gistid,))
 
         try:
--- a/kallithea/model/db.py	Mon Sep 19 14:46:12 2016 +0200
+++ b/kallithea/model/db.py	Thu Oct 27 18:33:42 2016 +0200
@@ -2525,7 +2525,7 @@
     gist_id = Column(Integer(), primary_key=True)
     gist_access_id = Column(Unicode(250), nullable=False)
     gist_description = Column(UnicodeText(), nullable=False)
-    gist_owner = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
+    owner_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
     gist_expires = Column(Float(53), nullable=False)
     gist_type = Column(Unicode(128), nullable=False)
     created_on = Column(DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
--- a/kallithea/model/gist.py	Mon Sep 19 14:46:12 2016 +0200
+++ b/kallithea/model/gist.py	Thu Oct 27 18:33:42 2016 +0200
@@ -118,7 +118,7 @@
         gist = Gist()
         gist.gist_description = description
         gist.gist_access_id = gist_id
-        gist.gist_owner = owner.user_id
+        gist.owner_id = owner.user_id
         gist.gist_expires = gist_expires
         gist.gist_type = safe_unicode(gist_type)
         self.sa.add(gist)
--- a/kallithea/templates/admin/gists/show.html	Mon Sep 19 14:46:12 2016 +0200
+++ b/kallithea/templates/admin/gists/show.html	Thu Oct 27 18:33:42 2016 +0200
@@ -50,7 +50,7 @@
                          %endif
                         </div>
 
-                       %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.authuser.user_id:
+                       %if h.HasPermissionAny('hg.admin')() or c.gist.owner_id == c.authuser.user_id:
                         <div style="float:right">
                             ${h.form(url('gist_delete', gist_id=c.gist.gist_id))}
                                 ${h.submit('remove_gist', _('Delete'),class_="btn btn-danger btn-xs",onclick="return confirm('"+_('Confirm to delete this Gist')+"');")}
@@ -59,7 +59,7 @@
                        %endif
                         <div class="buttons">
                           ## only owner should see that
-                          %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.authuser.user_id:
+                          %if h.HasPermissionAny('hg.admin')() or c.gist.owner_id == c.authuser.user_id:
                             ${h.link_to(_('Edit'),h.url('edit_gist', gist_id=c.gist.gist_access_id),class_="btn btn-default btn-xs")}
                           %endif
                           ${h.link_to(_('Show as Raw'),h.url('formatted_gist', gist_id=c.gist.gist_access_id, format='raw'),class_="btn btn-default btn-xs")}