Skip to content
Browse files

did stuff

  • Loading branch information...
1 parent 0fa6aea commit d3dccc59df62da075a1138c3be87e1f7cb1b81e6 Justine Tunney committed Apr 19, 2012
Showing with 75 additions and 7 deletions.
  1. +1 −1 Makefile
  2. +9 −0 notes.org
  3. +65 −6 sparkles/models.py
View
2 Makefile
@@ -17,7 +17,7 @@ dev:
pyflakes sparkles/api.py
pep8 sparkles/message.py
pyflakes sparkles/message.py
- sparkles-dev syncdb
+ sparkles-dev syncdb --noinput
sparkles-dev migrate
sparkles-dev test sparkles
make -C doc html
View
9 notes.org
@@ -5,6 +5,7 @@
** Absolute voting bans you from group if decision goes against you
* Justine's Hours
** System Design
+ CLOCK: [2012-03-29 Thu 20:34]--[2012-03-29 Thu 23:50] => 3:16
CLOCK: [2012-02-03 Fri 20:24]--[2012-02-03 Fri 20:28] => 0:04
CLOCK: [2012-02-03 Fri 02:51]--[2012-02-03 Fri 04:30] => 1:39
** Signup & Messaging
@@ -27,6 +28,14 @@
** [[http://www.casagordita.com/consensus.htm][Consensus Description]]
** [[http://libcom.org/files/consensus.pdf][Blocking Progress: Consensus Decision Making in the Anti-Nuclear Movement]]
* Similar Projects
+** [[http://justify.media.mit.edu:9090/users/login][Justify from MIT]]
+
+ The guys who made this, I don't know what parallel universe they exist in
+ that made them think this design would be something that'd help people
+ communicate better. It's almost so bad that like, I feel bad disparaging
+ this software because it's as though i'm ridiculing a child for not
+ coloring inside the lines.
+
** [[http://bettermeans.com/front/index.html][Better Means]] ([[https://github.com/Bettermeans/bettermeans][Source Code]]) ([[https://collaborate.occupy.net/][collaborate.occupy.net]])
*** More project management focused than decision making
*** Designed for medium sized organizations to replace organizational structure and redefine interpersonal relationships in the workplace
View
71 sparkles/models.py
@@ -9,6 +9,7 @@
"""
+import json
import logging
import functools
@@ -19,7 +20,7 @@
logger = logging.getLogger(__name__)
-redis = redis.StrictRedis()
+redisc = redis.StrictRedis()
rng = open('/dev/urandom')
@@ -51,6 +52,15 @@ def base36(amt=7):
return ''.join([choices[ord(b) % 36] for b in rng.read(amt)])
+def user_dict(user):
+ return {
+ 'id': user.id,
+ 'email': user.username,
+ 'first_name': user.first_name,
+ 'last_name': user.last_name,
+ }
+
+
class UserInfo(models.Model):
"""Extra DB information to associate with a Django auth user"""
user = models.OneToOneField(User, editable=False, help_text="""
@@ -169,12 +179,14 @@ def get_content(self):
return self.texts.order_by('-created')[0]
def set_content(self, user, content):
- ProposalText.objects.create(prop=self, user=user, content=content)
+ p = ProposalText.objects.create(prop=self, user=user, content=content)
+ p.publish()
content = property(get_content, set_content)
def log(self, user, content):
- ProposalLog.objects.create(prop=self, user=user, content=content)
+ p = ProposalLog.objects.create(prop=self, user=user, content=content)
+ p.publish()
class ProposalText(models.Model):
@@ -186,6 +198,17 @@ class ProposalText(models.Model):
content = models.TextField(blank=True, help_text="""
The text of the proposal in markdown""")
+ def publish(self):
+ redisc.publish('sparkles-event', json.dumps({
+ 'channel': 'proposal-' + self.prop.sid,
+ 'type': 'text',
+ 'text': {
+ 'content': self.content,
+ 'created': self.created.strftime("%s"),
+ 'user': user_dict(self.user),
+ }
+ }))
+
class ProposalChat(models.Model):
"""Proposal text revisions"""
@@ -196,6 +219,17 @@ class ProposalChat(models.Model):
content = models.TextField(help_text="""
Arbitrary line of text in markdown""")
+ def publish(self):
+ redisc.publish('sparkles-event', json.dumps({
+ 'channel': 'proposal-' + self.prop.sid,
+ 'type': 'chat',
+ 'chat': {
+ 'content': self.content,
+ 'created': self.created.strftime("%s"),
+ 'user': user_dict(self.user),
+ }
+ }))
+
class ProposalLog(models.Model):
"""Proposal action log"""
@@ -206,14 +240,27 @@ class ProposalLog(models.Model):
content = models.TextField(help_text="""
Arbitrary line of text in markdown""")
+ def publish(self):
+ redisc.publish('sparkles-event', json.dumps({
+ 'channel': 'proposal-' + self.prop.sid,
+ 'type': 'log',
+ 'log': {
+ 'content': self.content,
+ 'created': self.created.strftime("%s"),
+ 'user': user_dict(self.user),
+ }
+ }))
+
class ProposalVote(models.Model):
"""A person's vote and justification with revisions"""
VOTES = (
- ('', 'Unanswered'),
- ('good', 'Sparkles'),
- ('middle', 'Middling'),
+ ('', 'Pending'),
+ ('absgood', 'Absolute Support'),
+ ('good', 'Support'),
+ ('mid', 'Middling'),
('bad', 'Opposed'),
+ ('absbad', 'Absolute Oppose'),
('abstain', 'Abstain'),
)
@@ -226,6 +273,18 @@ class ProposalVote(models.Model):
content = models.TextField(blank=True, help_text="""
Why do you feel this way?""")
+ def publish(self):
+ redisc.publish('sparkles-event', json.dumps({
+ 'channel': 'proposal-' + self.prop.sid,
+ 'type': 'vote',
+ 'vote': {
+ 'vote': self.vote,
+ 'content': self.content,
+ 'created': self.created.strftime("%s"),
+ 'user': user_dict(self.user),
+ }
+ }))
+
class EmailBlacklist(models.Model):
"""Never email these people under any circumstances"""

0 comments on commit d3dccc5

Please sign in to comment.
Something went wrong with that request. Please try again.