Remove 'Stash' from class names.
authorMikko Värri <vmj@linuxbox.fi>
Thu, 11 Aug 2011 18:03:49 +0000 (21:03 +0300)
committerMikko Värri <vmj@linuxbox.fi>
Thu, 11 Aug 2011 18:03:49 +0000 (21:03 +0300)
recycloid_models/admin.py
recycloid_models/management/__init__.py
recycloid_models/management/commands/createstashserver.py
recycloid_models/managers.py
recycloid_models/models.py

index a87b500..05dc482 100644 (file)
@@ -9,10 +9,10 @@ from django.contrib import admin
 from recycloid_models import models
 
 
-class StashServerAdmin(admin.ModelAdmin):
+class ServerAdmin(admin.ModelAdmin):
     pass
 
-class StashOwnerAdmin(admin.ModelAdmin):
+class OwnerAdmin(admin.ModelAdmin):
     list_filter = ('server',)
     search_fields = ('description',)
 
@@ -21,17 +21,17 @@ class StashAdmin(admin.ModelAdmin):
     list_filter = ('owner',)
     search_fields = ('title', 'description')
 
-class StashItemAdmin(admin.ModelAdmin):
+class ItemAdmin(admin.ModelAdmin):
     list_display = ('title', 'created', 'expires', 'modified')
     list_filter = ('stash', 'created', 'expires', 'modified')
     search_fields = ('title', 'description')
 
-class StashItemImageAdmin(admin.ModelAdmin):
+class ImageAdmin(admin.ModelAdmin):
     list_filter = ('item',)
 
 
-admin.site.register(models.StashServer, StashServerAdmin)
-admin.site.register(models.StashOwner, StashOwnerAdmin)
+admin.site.register(models.Server, ServerAdmin)
+admin.site.register(models.Owner, OwnerAdmin)
 admin.site.register(models.Stash, StashAdmin)
-admin.site.register(models.StashItem, StashItemAdmin)
-admin.site.register(models.StashItemImage)
+admin.site.register(models.Item, ItemAdmin)
+admin.site.register(models.Image)
index 0508c57..27e73e8 100644 (file)
@@ -9,12 +9,12 @@ def create_stashserver(sender, **kwargs):
     recycloid_models is first installed.
     """
     from django.core.management import call_command
-    from recycloid_models.models import StashServer
+    from recycloid_models.models import Server
 
     interactive = kwargs.get('interactive', False)
     created_models = kwargs.get('created_models', [])
 
-    if interactive and StashServer in created_models:
+    if interactive and Server in created_models:
         msg = "\nYou just installed Recycloid's models, which means " \
               "you don't have any servers defined.\nWould you like " \
               "to create one now? (yes/no): "
index 0600b28..9d93cc2 100644 (file)
@@ -2,14 +2,14 @@ import sys
 from optparse import make_option
 from django.core.exceptions import ValidationError
 from django.core.management.base import BaseCommand, CommandError
-from recycloid_models.models import StashServer
+from recycloid_models.models import Server
 
 
 def is_valid_url(value):
     #[TODO] Validate against URLField
     try:
-        StashServer.objects.get(url=value)
-    except StashServer.DoesNotExist:
+        Server.objects.get(url=value)
+    except Server.DoesNotExist:
         pass
     else:
         raise ValidationError('URL is already taken.')
@@ -63,5 +63,5 @@ class Command(BaseCommand):
                 sys.stderr.write("\nOperation cancelled.\n")
                 sys.exit(1)
 
-        server = StashServer.objects.create(url=url)
-        print "StashServer created succesfully."
+        server = Server.objects.create(url=url)
+        print "Server created succesfully."
index f35fc50..4733c47 100644 (file)
@@ -3,8 +3,8 @@ from django.db.models import Manager
 import settings
 
 
-class StashServerManager(Manager):
-    """Manager for StashServers.
+class ServerManager(Manager):
+    """Manager for Servers.
     """
 
     def current(self):
index ea7d3dc..1fd3d8f 100644 (file)
@@ -8,7 +8,7 @@ from django.db import models
 from django.db.models.signals import post_save, pre_delete
 
 from recycloid_models.utils import uuid as _uuid
-from recycloid_models.managers import StashServerManager
+from recycloid_models.managers import ServerManager
 
 
 class IdentifiedModel(models.Model):
@@ -27,27 +27,27 @@ class IdentifiedModel(models.Model):
         raise NotImplementedError()
 
 
-class StashServer(IdentifiedModel):
+class Server(IdentifiedModel):
     """Stash server.
     """
 
     url = models.URLField(unique=True, help_text='API URL of this server')
 
-    objects = StashServerManager()
+    objects = ServerManager()
 
     def __unicode__(self):
         return u'%s' % self.url
 
 
-class StashOwner(IdentifiedModel):
+class Owner(IdentifiedModel):
     """Stash owner.
 
     This is an extension of django.contrib.auth.models.User model,
     i.e. there's one-to-one relationship between them.  Note that not
-    all User instances necessarily have a corresponding StashOwner
+    all User instances necessarily have a corresponding Owner
     instance (e.g. staff or superusers created before recycloid_models
-    was installed), and not all StashOwner instances have a
-    corresponging User instance (e.g. remove StashOwners whose data is
+    was installed), and not all Owner instances have a
+    corresponging User instance (e.g. remove Owners whose data is
     cached by this server).
 
     One stash server may have zero or more stash owners.
@@ -56,7 +56,7 @@ class StashOwner(IdentifiedModel):
     user = models.ForeignKey(User, unique=True, null=True, blank=True,
                              help_text='Optional link to registered user')
 
-    server = models.ForeignKey(StashServer,
+    server = models.ForeignKey(Server,
                                help_text='Home server of the stash owner')
 
     thumbnail = models.URLField(blank=True, help_text='Optional URL of the avatar image')
@@ -69,9 +69,9 @@ class StashOwner(IdentifiedModel):
         return u'Remote stash owner %s' % self.uuid
 
     def get_owner(self):
-        """Returns the StashOwner.
+        """Returns the Owner.
 
-        :return: An instance of recycloid_models.models.StashOwner
+        :return: An instance of recycloid_models.models.Owner
         """
         return self
 
@@ -84,7 +84,7 @@ class Stash(IdentifiedModel):
     One stash server may have zero or more stashes.
     """
 
-    owner = models.ForeignKey(StashOwner)
+    owner = models.ForeignKey(Owner)
 
     latitude = models.DecimalField(max_digits=8, decimal_places=6,
                                    help_text='WGS84 latitude coordinate [-90..90])')
@@ -106,14 +106,14 @@ class Stash(IdentifiedModel):
         return u'%s' % self.title
 
     def get_owner(self):
-        """Returns the StashOwner.
+        """Returns the Owner.
 
-        :return: An instance of recycloid_models.models.StashOwner
+        :return: An instance of recycloid_models.models.Owner
         """
         return self.owner
 
 
-class StashItem(IdentifiedModel):
+class Item(IdentifiedModel):
     """An item in a stash.
 
     One stash may have zero or more stash items.
@@ -139,20 +139,20 @@ class StashItem(IdentifiedModel):
         return u'%s' % self.title
 
     def get_owner(self):
-        """Returns the StashOwner.
+        """Returns the Owner.
 
-        :return: An instance of recycloid_models.models.StashOwner
+        :return: An instance of recycloid_models.models.Owner
         """
         return self.stash.get_owner()
 
 
-class StashItemImage(IdentifiedModel):
+class Image(IdentifiedModel):
     """Detailed image of a stash item.
 
     One stash item may have zero or more stash item images.
     """
 
-    item = models.ForeignKey(StashItem)
+    item = models.ForeignKey(Item)
 
     url = models.URLField(help_text='URL to the item image')
 
@@ -181,9 +181,9 @@ class StashItemImage(IdentifiedModel):
         return u'%s' % self.url
 
     def get_owner(self):
-        """Returns the StashOwner.
+        """Returns the Owner.
 
-        :return: An instance of recycloid_models.models.StashOwner
+        :return: An instance of recycloid_models.models.Owner
         """
         return self.item.get_owner()
 
@@ -191,15 +191,15 @@ class StashItemImage(IdentifiedModel):
 def on__user__post_save(sender, *args, **kwargs):
     """Callback for post_save signal from django.contrib.auth.models.User.
 
-    Creates a corresponding Recycloid StashOwner when User is
+    Creates a corresponding Recycloid Owner when User is
     created.
     """
     if kwargs.get('created', False):
         user = kwargs.get('instance', None)
         if user:
             try:
-                server = StashServer.objects.current()
-                owner = StashOwner.objects.create(user=user, server=server)
+                server = Server.objects.current()
+                owner = Owner.objects.create(user=user, server=server)
                 owner.save()
             except:
                 pass
@@ -209,9 +209,9 @@ post_save.connect(on__user__post_save, sender=User,
 
 
 def on__stash_item__post_save(sender, *args, **kwargs):
-    """Callback for post_save signal from StashItem
+    """Callback for post_save signal from Item
 
-    Increments the item_count in related Stash, if an StashItem
+    Increments the item_count in related Stash, if an Item
     was created.
     """
     if kwargs.get('created', False):
@@ -220,12 +220,12 @@ def on__stash_item__post_save(sender, *args, **kwargs):
             item.stash.item_count = item.stash.item_count + 1
             item.stash.save()
 
-post_save.connect(on__stash_item__post_save, sender=StashItem,
+post_save.connect(on__stash_item__post_save, sender=Item,
                   dispatch_uid="recycloid_models.models.on__stash_item__post_save")
 
 
 def on__stash_item__pre_delete(sender, *args, **kwargs):
-    """Callback for pre_delete signal from StashItem.
+    """Callback for pre_delete signal from Item.
 
     Decrements the item_count in related Stash.
     """
@@ -234,5 +234,5 @@ def on__stash_item__pre_delete(sender, *args, **kwargs):
         item.stash.item_count = item.stash.item_count - 1
         item.stash.save()
 
-pre_delete.connect(on__stash_item__pre_delete, sender=StashItem,
+pre_delete.connect(on__stash_item__pre_delete, sender=Item,
                    dispatch_uid="recycloid_models.models.on__stash_item__pre_delete")