コード例 #1
0
def delete_request(appointment_id):
    try:
        request = AppointmentRequest.objects.get(id=appointment_id)
        mentor = MentorProfile.objects.get(id=request.mentor_id)
        mentee = MenteeProfile.objects.get(id=appointment.mentee_id)
    except:
        msg = "No appointment or account found with that id"
        logger.info(msg)
        return create_response(status=422, message=msg)

    if mentee.email_notifications:
        start_time = appointment.timeslot.start_time.strftime(
            f"{APPT_TIME_FORMAT} GMT")
        res_email = send_email(
            recipient=mentee.email,
            subject="Mentee Appointment Notification",
            data={
                "name": mentor.name,
                "date": start_time,
                "approved": False
            },
            template_id=MENTEE_APPT_TEMPLATE,
        )
        if not res_email:
            logger.info("Failed to send email")

    request.status = APPT_STATUS["REJECTED"]
    request.save()
    return create_response(status=200, message=f"Success")
コード例 #2
0
def edit(fan_username):
    fan = User.get_or_none(User.username == fan_username)
    request = IdolFan.get_or_none((IdolFan.idol_id == current_user.id)
                                  & (IdolFan.fan_id == fan.id))
    request.approved = True
    request.save()
    send_email_approved(sender=current_user.username, receiver_email=fan.email)
    flash(u"Approved! The requester has been notified", 'success')
    return redirect(url_for('follows.new'))
コード例 #3
0
def decline_upgrade_request(request_id):
    """This function sets the "status" of an Upgrade Request to 'Declined'.
    Also, sets the "role" of the user to '0' (Buyer). Just in case the Admin changed their mind """

    request = UpgradeRequest.objects(id=request_id).first()
    request.status = "Declined"
    request.save()

    flash("Upgrade Request has been declined.")

    return redirect(url_for("notification.review_upgrade_requests"))
コード例 #4
0
ファイル: app.py プロジェクト: adamlamers/feature_request
def ensure_priorities(client, new_priority):
    requests = (FeatureRequest
                .select()
                .where(FeatureRequest.client == client,
                       FeatureRequest.client_priority >= new_priority)
                .order_by(FeatureRequest.client_priority))

    #shift all requests with the same or lower priority by 1,
    #so the new one can fit in the middle
    for request in requests:
        request.client_priority += 1
        request.save()
コード例 #5
0
def decline_request(item_id, request_id):
    """This function sets the "status" of a Buy Request to 'Declined'."""

    Item.objects(id=item_id).update_one(unset__buy_request_list=request_id)

    request = BuyRequest.objects(id=request_id).first()
    request.status = "Declined"
    request.save()

    flash("Buy Request has been Declined!")

    return redirect(url_for('notification.review_buy_request'))
コード例 #6
0
def approve_upgrade_request(request_id):
    """This function sets the "status" of an Upgrade Request to 'Approved'.
    Also, sets the "role" of the user to '1' (Seller)."""

    request = UpgradeRequest.objects(id=request_id).first()
    request.status = "Approved"
    request.save()

    request.user.role = 1
    request.user.save()

    flash("Upgrade Request has been approved.")

    return redirect(url_for("notification.review_upgrade_requests"))
コード例 #7
0
def approve_buy_request(item_id, request_id):
    """This function sets the "status" of a Buy Request to 'Approved'.
    Also, sets the "sold" attribute of the item to 'True'."""

    item = Item.objects(id=item_id).first()
    item.sold = True
    Item.objects(id=item_id).update_one(unset__buy_request_list=request_id)
    item.save()

    request = BuyRequest.objects(id=request_id).first()
    request.status = "Approved"
    request.save()

    flash("Item has been sold!")

    Item.objects(id=item_id).update_one(pull__buy_request_list=request_id)

    return redirect(url_for('notification.review_buy_request'))
コード例 #8
0
ファイル: lol_teamAPI.py プロジェクト: bintao/cteemo
	def post(self, user_id):
		args = teamParser.parse_args()
		profile = Profile.objects(user=user_id).first()
		if profile.LOLTeam is not None:
			raise InvalidUsage('Already joined a team')

		teamName = args['teamName']
		team = LOLTeam.objects(teamName=teamName).first()

		if team is None:
			raise InvalidUsage('Team not found',404)

		captain = team.captain
		request = Request.objects(user=captain.user,type='join').only('requests_list').first()
		if request is None:
			request = Request(user=captain.user,type='join')
			request.save()
		request.update(add_to_set__requests_list=profile)

		return {'status' : 'success'}
コード例 #9
0
def accept_request(fan_id):
    identity = get_jwt_identity()
    fan = User.get_by_id(fan_id)
    idol = User.get(username=identity)
    request = Follow.get(fan=fan, idol=idol, is_approve=False)
    if request:
        request.is_approve = True
        if request.save():
            return jsonify({'message': 'success'})
        else:
            return jsonify({'message': 'failed'})
    else:
        return jsonify({'message': 'Request Not Found'})
コード例 #10
0
ファイル: lol_teamAPI.py プロジェクト: bintao/cteemo
	def post(self, user_id):
		args = teamParser.parse_args()
		profileID = args['profileID']
		teamIntro = args['teamIntro']
	
		profile = Profile.objects(user=user_id).first()
		if profileID == profile.id:
			raise InvalidUsage('Cannot send request to yourself')

		team = profile.LOLTeam
		if profileID is None and teamIntro is not None:
			if team.captain is not profile:
				raise InvalidUsage('Unauthorized',401)
			team.teamIntro = teamIntro
			team.save()
			return {'status' : 'success'}
		# avoid illegal operation
		if team is None:
			abort(400)
		if team.captain != profile:
			raise InvalidUsage('Unauthorized',401)
		# query the player u want to invite
		profile = Profile.objects(id=profileID).first()
		if profile is None:
			raise InvalidUsage('Member not found',404)
		try:
			assert len(team.members) < 6
		except:
			raise InvalidUsage('Team is full',403)
		request = Request.objects(user=profile.user,type='invite').only('requests_list').first()
		if request is None:
			request = Request(user=profile.user,type='invite')
			request.save()
		request.update(add_to_set__requests_list=team.captain)

		return {'status' : 'success'}
コード例 #11
0
def update(acc_id, follower_id, accept):
    request = Account_follower.get((Account_follower.follower == follower_id)
                                   & (Account_follower.account_id == acc_id))
    follower = User.get_by_id(follower_id)

    if accept:
        request.approved = True

        if request.save():
            flash(f"You have accepted {follower.name}'s request!")
        else:
            flash("Unable to accept request")
            return render_template('home.html', errors=request.errors)

    else:
        request.delete_instance()
        flash(f"You have removed {follower.name}'s request.")
    return redirect(url_for('followers.index', acc_id=acc_id))
コード例 #12
0
 def make_request( cls, time, days_bit_mask, start_date, end_date, editor ):
     """ """
     request = cls( time = time, editor = editor, days_bit_mask = days_bit_mask,
         start_date = start_date, end_date = end_date )
     request.save()