Skip to content

Commit

Permalink
fixed clone creation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
frnsys committed Jul 17, 2014
1 parent 9f46c7f commit ee15b55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@
class Clone(db.Document):
created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
username = db.StringField(required=True, unique=True)
patterns = db.ListField(db.StringField(), required=True)
vocabulary = db.DictField(required=True)

# Mad-lib Tweet patterns.
patterns = db.ListField(db.StringField(), required=True, default=[])

# { POS tag: words }
vocabulary = db.DictField(required=True, default={})

meta = {
'allow_inheritance': True,
'indexes': ['-created_at', 'username'],
'ordering': ['-created_at']
}

def imprint(self, username):
def imprint(self):
"""
Generate a clone for a given Twitter user.
"""
self.username = username
user_tweets = twitter.tweets(username, count=2000)

# { POS tag: words }
self.vocabulary = {}

# Mad-lib Tweet patterns.
self.patterns = []
user_tweets = twitter.tweets(self.username, count=2000)

for tweet in user_tweets:
text = tweet['body']
Expand Down
2 changes: 1 addition & 1 deletion app/routes/clones.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def clones():
if form.validate_on_submit():
username = form.username.data
clone = Clone.objects.get_or_create(username=username)
clone.imprint(username)
clone.imprint()
clone.save()
return redirect(url_for('clones.clone', username=username))
return render_template('clones/create.jade', form=form)
Expand Down

0 comments on commit ee15b55

Please sign in to comment.