Ejemplo n.º 1
0
def show_timeline_before(timeline_id):
    if g.user_id:
        time_tag = Timeline.objects(id=timeline_id).first().create_at
        user = User.objects(id=g.user_id).first()
        timelines = Timeline.objects(Q(create_at__lt=time_tag)&Q(owner=g.user_id))[:5].order_by('-create_at')
        res_data = timeline_pack(timelines, user)
        return (json.dumps(res_data), 200)
    return ('timeline_before session timeout', 400)
Ejemplo n.º 2
0
def show_timeline():
    if g.user_id:
        user = User.objects(id=g.user_id).first()
        timelines = Timeline.objects(owner=g.user_id)[:5].order_by('-create_at')
        res_data = timeline_pack(timelines, user)
        return (json.dumps(res_data), 200)
    return ('timeline session timeout', 400)
Ejemplo n.º 3
0
def admin_del_user(user_id):
    if g.admin:
        user = User.objects(id=user_id).first()
        user.delete()
        pins = Pin.objects(owner=user_id)
        for pin in pins:
            pin.delete()
        timelines = Timeline.objects(owner=user_id)
        for timeline in timelines:
            timeline.delete()
        return redirect(url_for('admin.admin_user'))
    return redirect(url_for('admin.admin_login'))

    
Ejemplo n.º 4
0
def del_pin(pin_id):
    if g.user_id:
        if len(pin_id) == 24:
            pin = Pin.objects(id=pin_id).first()
            if pin:
                pin.delete()

                # delete pin from timeline
                timelines = Timeline.objects(pin=pin_id)
                for timeline in timelines:
                    timeline.delete()
      
                return ('delete success', 200)
            return ('no this pin', 400)
        return ('need pin_id', 400)
    return ('del pin session timeout', 400)