Guest User

Untitled

a guest
Sep 22nd, 2017
193
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/commands.py b/commands.py
  2. index 6b6aee2..efc9aca 100644
  3. --- a/commands.py
  4. +++ b/commands.py
  5. @@ -159,7 +159,7 @@ class BoardAdminCmd(default_cmds.MuxCommand):
  6. board.save()
  7. return
  8.  
  9. - self.msg("Unknown switch. Please see {555help " + self.cmdstring + "{n for help.")
  10. + self.msg("Unknown switch. Please see |555help " + self.cmdstring + "|n for help.")
  11.  
  12.  
  13. class BoardCmd(default_cmds.MuxCommand):
  14. @@ -233,7 +233,7 @@ class BoardCmd(default_cmds.MuxCommand):
  15. self.msg("The post identifier '" + readargs[1] + "' must be a positive integer!")
  16. return None
  17.  
  18. - board = DefaultBoard.objects.get_visible_board(self.player, boardname)
  19. + board = DefaultBoard.objects.get_visible_board(self.account, boardname)
  20. if not board:
  21. self.msg("Unable to find a board matching '" + string + "'!")
  22. return None
  23. @@ -241,7 +241,7 @@ class BoardCmd(default_cmds.MuxCommand):
  24. if len(readargs) == 1:
  25. return {"board": board, "post": None, "postnum": 0}
  26.  
  27. - posts = board.posts(self.player)
  28. + posts = board.posts(self.account)
  29.  
  30. if not (0 < postnum <= len(posts)):
  31. self.msg("There's no post by that number.")
  32. @@ -254,7 +254,7 @@ class BoardCmd(default_cmds.MuxCommand):
  33. # This is overly long, and could potentially use a refactor to split the switches out
  34. # into their own functions.
  35. def func(self):
  36. - caller = self.player
  37. + caller = self.account
  38.  
  39. boards = DefaultBoard.objects.get_all_visible_boards(caller)
  40. shortcut = False
  41. @@ -447,9 +447,9 @@ class BoardCmd(default_cmds.MuxCommand):
  42. self.msg("You don't have permission to post to " + board.name + "!")
  43. return
  44.  
  45. - postplayer = self.player
  46. + postplayer = self.account
  47. postobject = None
  48. - postname = self.player.name
  49. + postname = self.account.name
  50.  
  51. if self.caller is Object or self.caller is Character:
  52. postobject = self.caller
  53. @@ -499,9 +499,9 @@ class BoardCmd(default_cmds.MuxCommand):
  54. while post.db_parent:
  55. post = post.db_parent
  56.  
  57. - postplayer = self.player
  58. + postplayer = self.account
  59. postobject = None
  60. - postname = self.player.name
  61. + postname = self.account.name
  62.  
  63. if self.caller is Object or self.caller is Character:
  64. postobject = self.caller
  65. diff --git a/managers.py b/managers.py
  66. index 8ddb8f9..510aa17 100644
  67. --- a/managers.py
  68. +++ b/managers.py
  69. @@ -4,8 +4,8 @@ from django.db import models
  70. from django.db.models import Q
  71. from itertools import chain
  72. from datetime import datetime
  73. -from evennia.typeclasses.managers import (TypedObjectManager, TypeclassManager,
  74. - returns_typeclass_list, returns_typeclass)
  75. +from evennia.typeclasses.managers import TypedObjectManager, TypeclassManager
  76. +#returns_typeclass_list, returns_typeclass
  77.  
  78. _GA = object.__getattribute__
  79. _PlayerDB = None
  80. @@ -113,7 +113,8 @@ class PostQuerySet(models.query.QuerySet):
  81. """
  82. posts = self.by_board(board)
  83. for p in posts:
  84. - if player.read_posts.filter(pk=p.id).exists():
  85. + #### DEBUG ####
  86. + if account.read_posts.filter(pk=p.id).exists():
  87. setattr(p, "unread", False)
  88. else:
  89. setattr(p, "unread", True)
  90. @@ -153,11 +154,9 @@ class PostManager(TypedObjectManager):
  91. def get_queryset(self):
  92. return PostQuerySet(self.model, using=self._db)
  93.  
  94. - @returns_typeclass
  95. def post(self, id):
  96. return self.get_queryset().get(pk=id)
  97.  
  98. - @returns_typeclass_list
  99. def posts(self, board, player=None):
  100. """
  101. Given a board and an optional player, returns the posts
  102. @@ -174,7 +173,6 @@ class PostManager(TypedObjectManager):
  103. else:
  104. return self.get_queryset().by_board_for_player(board, player)
  105.  
  106. - @returns_typeclass_list
  107. def threads(self, board, player=None):
  108. """
  109. Given a board and an optional player, return the threads.
  110. @@ -188,7 +186,6 @@ class PostManager(TypedObjectManager):
  111. """
  112. return self.get_queryset().by_board_threaded_player(board, player)
  113.  
  114. - @returns_typeclass_list
  115. def search(self, searchstring, board=None):
  116. if board:
  117. result = self.get_queryset().by_board(board).filter(db_text__icontains=searchstring).\
  118. @@ -209,7 +206,6 @@ class BoardDBManager(TypedObjectManager):
  119.  
  120. """
  121.  
  122. - @returns_typeclass_list
  123. def get_all_boards(self):
  124. """
  125. Returns all boards.
  126. @@ -219,11 +215,9 @@ class BoardDBManager(TypedObjectManager):
  127. """
  128. return self.all()
  129.  
  130. - @returns_typeclass
  131. def get_board_id(self, id):
  132. return self.get(pk=id)
  133.  
  134. - @returns_typeclass
  135. def get_board(self, key):
  136. """
  137. Returns a specific board beginning with the key.
  138. @@ -248,7 +242,6 @@ class BoardDBManager(TypedObjectManager):
  139. except self.model.DoesNotExist:
  140. return None
  141.  
  142. - @returns_typeclass
  143. def get_board_exact(self, key):
  144. """
  145. Returns a specific board matching the key.
  146. @@ -269,7 +262,6 @@ class BoardDBManager(TypedObjectManager):
  147. return None
  148.  
  149.  
  150. - @returns_typeclass_list
  151. def get_all_visible_boards(self, caller):
  152. """
  153. This function returns all the boards visible to a given viewer.
  154. @@ -300,7 +292,6 @@ class BoardDBManager(TypedObjectManager):
  155.  
  156. return filtered
  157.  
  158. - @returns_typeclass
  159. def get_visible_board(self, viewer, key):
  160. """
  161. This function returns a single board matching the key, provided it's unique.
  162. @@ -339,7 +330,6 @@ class BoardDBManager(TypedObjectManager):
  163.  
  164. return None
  165.  
  166. - @returns_typeclass_list
  167. def get_subscriptions(self, subscriber):
  168. """
  169. This function returns a list of boards a given user is subscribed to.
  170. diff --git a/models.py b/models.py
  171. index 433b443..116bc8a 100644
  172. --- a/models.py
  173. +++ b/models.py
  174. @@ -26,7 +26,7 @@ class Post(SharedMemoryModel):
  175. - db_text: The actual text of the post.
  176.  
  177. """
  178. - db_poster_player = models.ForeignKey("players.PlayerDB", related_name="+", null=True, blank=True,
  179. + db_poster_player = models.ForeignKey("accounts.AccountDB", related_name="+", null=True, blank=True,
  180. verbose_name="poster(player)", db_index=True, help_text='Post origin (if player).')
  181. db_poster_object = models.ForeignKey("objects.ObjectDB", related_name="+", null=True, blank=True,
  182. verbose_name="poster(object)", db_index=True, help_text='Post origin (if object),')
  183. @@ -37,7 +37,7 @@ class Post(SharedMemoryModel):
  184. db_date_created = models.DateTimeField('date created', editable=False,
  185. auto_now_add=True, db_index=True, help_text='Date post was made.')
  186. db_pinned = models.BooleanField(verbose_name="pinned", help_text='Should the post remain visible even after expiration?')
  187. - db_readers = models.ManyToManyField("players.PlayerDB", related_name="read_posts", null=True, blank=True,
  188. + db_readers = models.ManyToManyField("accounts.AccountDB", related_name="read_posts", null=True, blank=True,
  189. verbose_name="readers", help_text='Players who have read this post.')
  190. db_parent = models.ForeignKey('Post', verbose_name='parent', related_name='replies', null=True, blank=True,
  191. help_text='Parent/child map for threaded replies.')
  192. @@ -221,7 +221,7 @@ class BoardDB(TypedObject):
  193. help_text='Maximum number of active/visible posts for this board.')
  194. db_expiry_duration = models.IntegerField('lifetime_days', blank=True, null=True,
  195. help_text='Maximum timeline in days for posts to live on this board.')
  196. - db_subscriptions = models.ManyToManyField('players.PlayerDB', blank=True, verbose_name='subscribers',
  197. + db_subscriptions = models.ManyToManyField('accounts.AccountDB', blank=True, verbose_name='subscribers',
  198. related_name='board_subscriptions',
  199. help_text='Players subscribed to this board.')
RAW Paste Data