Exemplo n.º 1
0
def push_follow_notification(follower, receiver):
    '''推送关注提醒'''
    message = '<a href="%s">%s</a> 关注了你。' % \
              (url_for('user.index', username=follower.username), follower.username)
    notification = Notification(message=message, receiver=receiver)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 2
0
def fake_notification(count=100):
    for i in range(count):
        notification = Notification(message=fake.sentence(),
                                    receiver=User.query.get(
                                        random.randint(1, User.query.count())))
        db.session.add(notification)
    db.session.commit()
Exemplo n.º 3
0
def push_collect_notification(collector, photo_id, receiver):
    '''推送收藏提醒'''
    message = '<a href="%s">%s</a> 收藏了你的 <a href="%s">照片</a>' % \
              (url_for('user.index', username=collector.username), collector.username, url_for('main.show_photo', photo_id=photo_id))
    notification = Notification(message=message, receiver=receiver)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 4
0
def push_comment_notification(photo_id, receiver, page=1):
    '''推送评论提醒'''
    message = '<a href="%s">这张照片</a>有一个新的评论或回复。' % \
              (url_for('main.show_photo', photo_id=photo_id, page=page))
    notification = Notification(message=message, receiver=receiver)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 5
0
    def test_read_all_notification(self):
        user = User.query.get(2)
        notification1 = Notification(message='test 1', receiver=user)
        notification2 = Notification(message='test 2', receiver=user)
        db.session.add_all([notification1, notification2])
        db.session.commit()

        self.login()

        response = self.client.post(url_for('main.read_all_notification'),
                                    follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertIn('All notifications archived.', data)

        self.assertTrue(Notification.query.get(1).is_read)
        self.assertTrue(Notification.query.get(2).is_read)
Exemplo n.º 6
0
def push_invite_accept_notification(photo, sender, receipt_url, amount):
    print(type(amount))
    message = '<a href="%s" > Dr %s  has been hired for you.</a> You paid <a href="%s">%.2f $ </a> for this.' % \
              (url_for('main.show_photo', photo_id=photo.id), sender.username,receipt_url,amount)
    notification = Notification(message=message, receiver=photo.author)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 7
0
def push_collect_notification(collector, photo_id, receiver):
    message = 'User<a href="%s">%s</a> collected your <a href="%s">photo</a>' % \
              (url_for('user.index', username=collector.username), collector.username,
               url_for('main.show_photo', photo_id=photo_id))
    notification = Notification(message, receiver=receiver)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 8
0
def fake_admin():
	admin = User(name='Laonana', username='******', email='*****@*****.**', bio=fake.sentence(), website='http://laonana.com', confirmed=True)
	admin.set_password('password')
	notification = Notification(message='Hello, welcome to Albumy.', receiver=admin)
	db.session.add(notification)
	db.session.add(admin)
	db.session.commit()
Exemplo n.º 9
0
def push_comment_notification(photo_id, receiver, page=1):
    """照片被人评论时推送"""
    message = "<a href='%s#comments'>This photo </a> has new comment/reply." % \
              url_for('main.show_photo', photo_id=photo_id, page=page)
    notification = Notification(message=message, receiver=receiver)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 10
0
def edit_withdraws(withdraw_id):
    withdraw = WithDraw.query.get_or_404(withdraw_id)
    if request.method == 'GET':
        return render_template('admin/edit_withdraws.html', withdraw=withdraw)
    if request.method == 'POST':
        status = request.form['status']
        if status == 'pending':
            status = False
        elif status == 'verified':
            status = True
        if withdraw.status == status:
            return redirect(url_for('admin.manage_withdraws'))
        withdraw.status = status
        message = 'Requested the <a href="%s"> Withdraw </a> status has been updated.' % \
              (url_for('main.withdraw'))
        notification = Notification(message=message,
                                    receiver=withdraw.doctor.user)
        db.session.add(notification)
        if status == True:
            user = withdraw.doctor.user
            user.doctor.balance = user.doctor.balance - withdraw.amount
            transaction = Transaction(
                patient_name=current_user.username,
                doctor_name=user.username,
                token_id='unknown',
                acct_id='unknown',
                amount=str(withdraw.amount * 100),
                currency='USD',
                balance_transaction='unknown',
                description='Admin Paid to the Doctor Manually')
            db.session.add(transaction)
        db.session.commit()
        flash('WithDraw Status Has Been Changed', 'info')
        return redirect(url_for('admin.manage_withdraws'))
Exemplo n.º 11
0
def push_follow_notification(follower, receiver):
    """当被人关注时推送"""
    message = 'User <a href="%s">%s</a> followed you.' % \
              (url_for('user.index', username=follower.username), follower.username)
    notification = Notification(message=message, receiver=receiver)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 12
0
def fake_admin():
    admin = User(name='Mia Li',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='http://miali.com',
                 confirmed=True)
    admin.password = '******'
    admin.notifications.append(
        Notification(message='Hello, welcome to Albumy.'))
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 13
0
def fake_admin():
    admin = User(name='Grey Li',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='http://greyli.com',
                 confirmed=True)
    admin.set_password('helloflask')
    notification = Notification(message='Hello, welcome to Albumy.', receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 14
0
def fake_admin():
    admin = User(name='shui',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='http://www.phspshui.xyz',
                 confirmed=True)
    admin.set_password('123456')
    notification = Notification(message='你好,欢迎来到Albumy', receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 15
0
def fake_admin():
    admin = User(name='Hong Zhe',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 confirmed=True,
                 website='https://github.com/authetic-x')
    admin.set_password('123456')
    notification = Notification(message='Welcome to Albumy!', receiver=admin)
    db.session.add(admin)
    db.session.add(notification)
    db.session.commit()
Exemplo n.º 16
0
def push_comment_notification(photo_id, receiver, page=1):
	"""
	有新评论消息提醒
	:param photo_id: 图片id
	:param receiver: 接收者
	:param page: 页码
	"""
	message = '<a href="%s#comments">图片</a> 有新的评论\回复' % (
		url_for("main.show_photo", photo_id=photo_id, page=page)
	)
	notification = Notification(message=message, receiver=receiver)
	db.session.add(notification)
	db.session.commit()
Exemplo n.º 17
0
def fake_admin():
    admin = User(name='Mojerro',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='https://github.com/gaojx97',
                 confirmed=True)
    admin.set_password('TulipsTree')
    notification = Notification(message='Hello, welcome to TulipsTree.',
                                receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 18
0
def fake_admin():
    admin = User(name='Yang',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='http://123.com',
                 confirmed=True)
    admin.set_password('123456')
    notification = Notification(message='Hello, welcome to Albumy.',
                                receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 19
0
    def test_read_notification(self):
        user = User.query.get(2)
        notification1 = Notification(message='test 1', receiver=user)
        notification2 = Notification(message='test 2', receiver=user)
        db.session.add_all([notification1, notification2])
        db.session.commit()

        self.login(email='*****@*****.**', password='******')
        response = self.client.post(
            url_for('main.read_notification', notification_id=1))
        self.assertEqual(response.status_code, 403)

        self.logout()
        self.login()

        response = self.client.post(url_for('main.read_notification',
                                            notification_id=1),
                                    follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertIn('Notification archived.', data)

        self.assertTrue(Notification.query.get(1).is_read)
Exemplo n.º 20
0
    def test_show_notifications(self):
        user = User.query.get(2)
        notification1 = Notification(message='test 1',
                                     is_read=True,
                                     receiver=user)
        notification2 = Notification(message='test 2',
                                     is_read=False,
                                     receiver=user)
        db.session.add_all([notification1, notification2])
        db.session.commit()

        self.login()
        response = self.client.get(url_for('main.show_notifications'))
        data = response.get_data(as_text=True)
        self.assertIn('test 1', data)
        self.assertIn('test 2', data)

        response = self.client.get(
            url_for('main.show_notifications', filter='unread'))
        data = response.get_data(as_text=True)
        self.assertNotIn('test 1', data)
        self.assertIn('test 2', data)
Exemplo n.º 21
0
def fake_admin():
    admin = User(name='Sunhongze',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='http://www.shzll.top',
                 confirmed=True)
    admin.set_password('19970407')
    notification = Notification(message='Hello, welcome to albumy',
                                receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 22
0
def fake_admin():
    admin = User(name='admin',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='http://albumy.synvn.top',
                 confirmed=True)
    admin.set_password('admin')
    notification = Notification(message='Hello, welcome to Albumy.',
                                receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 23
0
def fake_admin():
    admin = User(name='QinHaiNing',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='https://www.triplet.com.cn',
                 confirmed=True)
    admin.set_password('helloflask')
    notification = Notification(message='Hello, welcome to Albumy.',
                                receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 24
0
def fake_admin():
    admin = User(name='Yuhan Yang',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website="",
                 confirmed=True)
    admin.set_password('helloflask')
    for i in range(10):
        notification = Notification(message='Hello, welcome to Albumy %d.' % i,
                                    receiver=admin)
        db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 25
0
def fake_admin():
    admin = User(name='HaiChong',
                 username='******',
                 email='*****@*****.**',
                 bio=fake.sentence(),
                 website='www.haichong.xyz',
                 confirmed=True)

    admin.set_password('123456')
    notification = Notification(message='Hello, welcome to Albumy.',
                                receiver=admin)
    db.session.add(notification)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 26
0
def fake_admin():
    admin = User(
        name="Jiang Yue",
        username="******",
        email="*****@*****.**",
        bio=fake.sentence(),
        website="http://example.com",
        confirmed=True,
    )
    admin.set_password("helloflask")
    notification = Notification(message="Hello welcome to Albumy.",
                                receiver=admin)
    db.session.add(admin)
    db.session.commit()
Exemplo n.º 27
0
def push_follow_notification(follower, receiver):
	"""
	有新用户关注
	:param follower: 关注者
	:param receiver: 接收消息用户对象
	"""
	# 两个参数分别是用户首页,和关注者的用户名
	message = '用户 <a href="%s">%s</a> 关注了你。' % (
		url_for("user.index", username=follower.username),
		follower.username,
	)
	# 将message发送给receiver
	notification = Notification(message=message, receiver=receiver)
	# 存入数据库
	db.session.add(notification)
	db.session.commit()
Exemplo n.º 28
0
def fake_admin():
	"""
	创建管理员账号
	"""
	admin = User(
		name="FlynnGod",
		username="******",
		email="*****@*****.**",
		bio=fake.sentence(),
		website="http://qxinhai.cn",
		confirmed=True,
	)
	admin.set_password("12345678")
	notification = Notification(message="Hello, welcome to Albumy.", receiver=admin)
	db.session.add(notification)
	db.session.add(admin)
	db.session.commit()
Exemplo n.º 29
0
def push_collect_notification(collector, photo_id, receiver):
	"""
	有新的收藏消息提醒
	:param collector: 收藏者对象
	:param photo_id: 图片id
	:param receiver: 接收消息对象
	"""
	message = '用户 <a href="%s">%s</a> 收藏了你的 <a href="%s">图片</a>' % (
		# 用户主页和用户名
		url_for("user.index", username=collector.username),
		collector.username,
		# 图片
		url_for("main.show_photo", photo_id=photo_id),
	)
	notification = Notification(message=message, receiver=receiver)
	db.session.add(notification)
	db.session.commit()
Exemplo n.º 30
0
def fake_user(count=10):
    for i in range(count):
        user = User(name=fake.name(),
                    username=fake.user_name(),
                    confirmed=True,
                    bio=fake.sentence(),
                    location=fake.city(),
                    website=fake.url(),
                    member_since=fake.date_this_decade(),
                    email=fake.email())
        user.password = '******'
        user.notifications.append(
            Notification(message='Hello, welcome to Albumy.'))
        db.session.add(user)
        try:
            db.session.commit()
        except IntegrityError:
            db.session.rollback()