Esempio n. 1
0
def manualentry():
    form = ManualEntryForm()
    if form.validate_on_submit():
        if form.inPerson.data:
            db.session.add(
                Queue(timestamp=datetime.utcnow(),
                      studentID=form.studentID.data,
                      location='in-person'))
        elif form.online.data:
            db.session.add(
                Queue(timestamp=datetime.utcnow(),
                      studentID=form.studentID.data,
                      location='online'))
        else:
            logging.critical(
                f"{request.remote_addr} - - [APP] A teacher attempted to manually enter {form.studentID.data}, but something went wrong."
            )
            flash("Something went wrong!", 'danger')
            redirect(url_for('teachers'))
        logging.info(
            f"{request.remote_addr} - - [APP] {form.studentID.data} added successfully by a teacher to the queue."
        )
        db.session.commit()
        return redirect(url_for('teachers'))
    return render_template('manualentry.html', form=form)
Esempio n. 2
0
def lock_upload():
    """
    Lock upload of repositories to DB.
    """

    queue = Queue.objects.filter(Q(in_progress=True)
                                 | Q(in_progress=False)).first()
    if queue:
        if not queue.in_progress:
            queue.in_progress = True
            queue.save()
    else:
        queue = Queue(in_progress=True)
        queue.save()
Esempio n. 3
0
    def post_queue(request):
        try:
            org_domain = request.form['org_domain']
            organization = Organization.query.filter_by(
                org_domain=org_domain).first()

            if not organization:
                return dict(status='FAIL',
                            message='No such organization',
                            error='Invalid number format',
                            request_args=request.form)

            queue_name = request.form['queue_name']
            queue_org_id = organization.org_id
            queue_group_id = request.form['queue_group_id']
            queue = Queue(queue_name=queue_name,
                          queue_org_id=queue_org_id,
                          queue_group_id=queue_group_id)
            db.session.add(queue)
            db.session.commit()

            return dict(status='OK',
                        message='Queue created successfully.',
                        error=None)
        except Exception as e:
            return dict(status='FAIL',
                        message='Could not create that queue.',
                        error=str(e),
                        request_args=request.form)
Esempio n. 4
0
    def pay_success(order, params=None):
        with db.auto_commit(throw=False):
            if not order or order.order_status_enum != OrderStatus.UNPAID:
                return True
            order.pay_sn = params.get('transaction_id', '')
            order.order_status_enum = OrderStatus.PAID
            order.pay_time = now_timestamp()
            db.session.add(order)

            order_foods = order.order_foods.all()
            for item in order_foods:
                food_sale_log = FoodSaleChangeLog()
                food_sale_log.food_id = item.food_id
                food_sale_log.quantity = item.quantity
                food_sale_log.total_price = item.total_price
                food_sale_log.member_id = order.member_id
                db.session.add(food_sale_log)

        Queue.add_queue('pay', {
            'member_id': order.member_id,
            'order_id': order.id
        })
        return True
Esempio n. 5
0
def queue():
    form = DocqueueForm()
    if form.validate_on_submit():
        q = Queue(
            name=form.name.data,
            age=form.age.data,
            sex=form.selectsex.data,
            tel=form.tele.data,
            for_time1=today,
            user_id=current_user.id,
        )
        db.session.add(q)
        db.session.commit()
        flash('成功挂号排队')
        resp = redirect(url_for('doctor.dealqueue'))
        resp.set_cookie('name', form.name.data)
        return resp
    return render_template('doctor/queue.html', form=form)
def queueQueues():
    current_user = get_jwt_identity()
    current_user_claims = get_jwt_claims()

    queueName = request.json.get("name", None)
    queueCron = request.json.get("cron", None)
    userId = current_user_claims.get('id', None)

    if queueName and queueCron and userId:
        with db_session() as s:
            newQueue = Queue(name=queueName, cron=queueCron, user_id=userId)
            s.add(newQueue)

            return {
                "msg": f"Queue '{queueName}' created."
            }, status.HTTP_201_CREATED

    return {
        f"msg": "An error occured on creating queue."
    }, status.HTTP_400_BAD_REQUEST
Esempio n. 7
0
def onlineSignin():
    form = OnlineSigninForm()
    if form.validate_on_submit():
        if getSettings()['closed']:
            logging.warning(
                f"{request.remote_addr} - - [APP] {form.studentID.data} attempted to register but the Queue was closed."
            )
            flash('Unfortunately, you were not added to the Queue.', 'warning')
        elif Student.query.get(form.studentID.data) is None:
            logging.critical(
                f"{request.remote_addr} - - [APP] {form.studentID.data} attempted to register online but the student ID is not in the database."
            )
            flash(
                f"Uh-Oh! Student ID {form.studentID.data} not found. Please contact your teacher.",
                'danger')
        elif Queue.query.filter_by(
                studentID=form.studentID.data).first() is not None:
            logging.warning(
                f"{request.remote_addr} - - [APP] {form.studentID.data} attempted to scan their student ID and enter the queue multiple times."
            )
            flash('You can only sign into the Queue one subject at a time.',
                  'warning')
        else:
            db.session.add(
                Queue(timestamp=datetime.utcnow(),
                      studentID=form.studentID.data,
                      location='online',
                      selectedSubject=form.subject.data))
            db.session.commit()
            logging.info(
                f"{request.remote_addr} - - [APP] {form.studentID.data} added successfully to the queue."
            )
            flash(
                'You have been successfully added to the Queue. Head to Google Chat.',
                'success')
            return redirect(url_for('public'))
        return redirect(url_for('onlineSignin'))
    return render_template('online_signin.html', form=form)
Esempio n. 8
0
def queue():
    form = QueueForm()
    addr = request.form.get('selectdoc')
    print(addr)
    print('***************************************************************')
    if form.validate_on_submit():
        q = Queue(name=form.name.data,
                  age=form.age.data,
                  sex=form.selectsex.data,
                  tel=form.tele.data,
                  desc=form.desc.data,
                  for_time1=form.dataselect.data,
                  user_id=current_user.id,
                  addr=form.docselect.data)

        u = User(username=form.name.data)

        db.session.add(q)
        db.session.add(u)
        db.session.commit()
        flash('您已成功挂号排队')
        return redirect(url_for('user.index'))
    doc = Doctor.query.filter(Doctor.id != None)
    return render_template('user/queue.html', form=form, doc=doc)
Esempio n. 9
0
def signin():
    form = SigninForm()
    if form.validate_on_submit():
        if getSettings()['closed']:
            logging.warning(
                f"[APP] {form.studentID.data - 200000000} attempted to register but the Queue was closed."
            )
            flash('Unfortunately, you were not added to the Queue.', 'warning')
            redirect(url_for('signin'))
        else:
            studentID = form.studentID.data - 200000000
            if Student.query.filter_by(id=studentID).first() is None:
                logging.warning(
                    f"[APP] {studentID} scanned their student ID card but no information found"
                )
                flash(
                    'Student information not found, please talk to a Tutorials Teacher',
                    'danger')
            elif Queue.query.filter_by(
                    studentID=studentID).first() is not None:
                logging.warning(
                    f"[APP] {studentID} attempted to scan their student ID and enter the queue multiple times."
                )
                flash(
                    'You can only sign into the Queue one subject at a time.',
                    'warning')
            else:
                logging.info(
                    f"[APP] {studentID} added successfully to the queue.")
                db.session.add(
                    Queue(timestamp=datetime.utcnow(),
                          studentID=studentID,
                          location='in-person'))
                db.session.commit()
            return redirect(url_for('signin'))
    return render_template('signin.html', form=form)
Esempio n. 10
0
def add_queue(request):
    context = {}
    queue = Queue()
    queue_name = request.GET['queue_name']
    spider_name = request.GET['spider_name']
    queue_ip = request.GET['queue_ip']
    queue_db = request.GET['queue_db']
    queue_describ = request.GET['queue_describ']
    queue.queue_name = queue_name
    queue.spider_name = spider_name
    queue.queue_ip = queue_ip
    queue.queue_port = DescrapyConstant.DEFAULT_DSCRAPY_REDIS_PORT
    queue.queue_db = queue_db
    queue.total_submit = 0
    queue.queue_describ = queue_describ
    queue.create_time = datetime.now()
    queue.deleted = DescrapyConstant.QUEUE_DELETED_NO
    qc = QueueControl()
    result = qc.add_queue(queue)
    context['message'] = result.status_message
    return render(request, 'queue_add.html', context)