Esempio n. 1
0
def create_external_subscribe_activity(youtify_user_model, external_user_model):
    target = simplejson.dumps(get_external_user_subscription_struct(external_user_model))
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model, verb='external_subscribe', actor=actor, target=target, type='outgoing')
    m.put()

    for relation in FollowRelation.all().filter('user2 =', youtify_user_model.key().id()):
        m = Activity(owner=YoutifyUser.get_by_id(relation.user1), verb='external_subscribe', actor=actor, target=target, type='incoming')
        m.put()
Esempio n. 2
0
def create_signup_activity(youtify_user_model):
    target = simplejson.dumps({})
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model,
                 verb='signup',
                 actor=actor,
                 target=target,
                 type='outgoing')
    m.put()
Esempio n. 3
0
 def post(self, event_id):
     activity_obj = json.loads(self.request.body)
     activity = Activity(
         parent=ndb.Key("Event", event_id),
         activityName=activity_obj["activityName"],
         createDateTime=datetime.now(),
         activityTips=activity_obj["activityTips"] if "activityTips" in activity_obj else None,
         healthTips=activity_obj["healthTips"] if "healthTips" in activity_obj else None,
         relationToOtherActivities=activity_obj["relationToOtherActivities"] if "relationToOtherActivities" in activity_obj else None)
     activity.put()
     self.response.out.write(json.dumps({"200":"Activity stored successfully.",
         "Details": activity_obj}))
Esempio n. 4
0
def create_follow_activity(owner, other_user):
    """ owner started following other_user 

    Both owner and other_user gets a new activity
    """
    target = simplejson.dumps(get_youtify_user_struct(other_user))
    actor = simplejson.dumps(get_youtify_user_struct(owner))

    m = Activity(owner=owner, verb='follow', actor=actor, target=target, type='outgoing')
    m.put()

    m = Activity(owner=other_user, verb='follow', actor=actor, target=target, type='incoming')
    m.put()
Esempio n. 5
0
def create_flattr_activity(youtify_user_model, thing_id, thing_title):
    target = simplejson.dumps({
        'thing_id': thing_id,
        'thing_title': thing_title,
    })
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model, verb='flattr', actor=actor, target=target, type='outgoing')
    m.put()

    for relation in FollowRelation.all().filter('user2 =', youtify_user_model.key().id()):
        m = Activity(owner=YoutifyUser.get_by_id(relation.user1), verb='flattr', actor=actor, target=target, type='incoming')
        m.put()
Esempio n. 6
0
def create_subscribe_activity(youtify_user_model, playlist_model):
    """ user subscribed to playlist

    Both user and playlists owner gets a new activity
    """
    target = simplejson.dumps(get_playlist_struct_from_playlist_model(playlist_model))
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model, verb='subscribe', actor=actor, target=target, type='outgoing')
    m.put()

    m = Activity(owner=playlist_model.owner, verb='subscribe', actor=actor, target=target, type='incoming')
    m.put()
Esempio n. 7
0
def create_external_subscribe_activity(youtify_user_model,
                                       external_user_model):
    target = simplejson.dumps(
        get_external_user_subscription_struct(external_user_model))
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model,
                 verb='external_subscribe',
                 actor=actor,
                 target=target,
                 type='outgoing')
    m.put()

    for relation in FollowRelation.all().filter('user2 =',
                                                youtify_user_model.key().id()):
        m = Activity(owner=YoutifyUser.get_by_id(relation.user1),
                     verb='external_subscribe',
                     actor=actor,
                     target=target,
                     type='incoming')
        m.put()
Esempio n. 8
0
def create_follow_activity(owner, other_user):
    """ owner started following other_user 

    Both owner and other_user gets a new activity
    """
    target = simplejson.dumps(get_youtify_user_struct(other_user))
    actor = simplejson.dumps(get_youtify_user_struct(owner))

    m = Activity(owner=owner,
                 verb='follow',
                 actor=actor,
                 target=target,
                 type='outgoing')
    m.put()

    m = Activity(owner=other_user,
                 verb='follow',
                 actor=actor,
                 target=target,
                 type='incoming')
    m.put()
Esempio n. 9
0
def create_flattr_activity(youtify_user_model, thing_id, thing_title):
    target = simplejson.dumps({
        'thing_id': thing_id,
        'thing_title': thing_title,
    })
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model,
                 verb='flattr',
                 actor=actor,
                 target=target,
                 type='outgoing')
    m.put()

    for relation in FollowRelation.all().filter('user2 =',
                                                youtify_user_model.key().id()):
        m = Activity(owner=YoutifyUser.get_by_id(relation.user1),
                     verb='flattr',
                     actor=actor,
                     target=target,
                     type='incoming')
        m.put()
Esempio n. 10
0
def create_subscribe_activity(youtify_user_model, playlist_model):
    """ user subscribed to playlist

    Both user and playlists owner gets a new activity
    """
    target = simplejson.dumps(
        get_playlist_struct_from_playlist_model(playlist_model))
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model,
                 verb='subscribe',
                 actor=actor,
                 target=target,
                 type='outgoing')
    m.put()

    m = Activity(owner=playlist_model.owner,
                 verb='subscribe',
                 actor=actor,
                 target=target,
                 type='incoming')
    m.put()
Esempio n. 11
0
def create_signup_activity(youtify_user_model):
    target = simplejson.dumps({})
    actor = simplejson.dumps(get_youtify_user_struct(youtify_user_model))

    m = Activity(owner=youtify_user_model, verb='signup', actor=actor, target=target, type='outgoing')
    m.put()
Esempio n. 12
0
 def json(self):
     activity = Activity(name=self.require("name"), user=user(),
         tags=Activity.parsetags(self.request.get("tags", "")))
     activity.put()
     return {"activity":render("activity", activity=activity)}