Пример #1
0
 def delete(self, news_id):
     abort_if_news_not_found(news_id)
     session = db_session.create_session()
     news = session.query(News).get(news_id)
     session.delete(news)
     session.commit()
     return jsonify({'success': 'OK'})
def create_news():
    if not request.json:
        return jsonify({'error': 'Empty request'})
    elif not all(key in request.json for key in [
            'id', 'job', 'team_leader', 'work_size', 'collaborators',
            'start_date', 'end_date', 'is_finished', 'category'
    ]):
        return jsonify({'error': 'Bad request'})
    session = db_session.create_session()
    news = Jobs(
        id=request.json['id'],
        job=request.json['job'],
        team_leader=request.json['team_leader'],
        work_size=request.json['work_size'],
        collaborators=request.json['collaborators'],
        start_date=request.json['start_date'],
        end_date=request.json['end_date'],
        is_finished=request.json['is_finished'],
        category=request.json['category'],
    )
    if not session.query(Jobs).filter(Jobs.id == news.id).first():
        return jsonify({'error': 'id not found'})
    session.delete(session.query(Jobs).get(request.json['id']))
    session.add(news)
    session.commit()
    return jsonify({'success': 'OK'})
Пример #3
0
def addel(brand_id):
	brand=session.query(Brand).filter_by(id=brand_id).one()
	session.delete(brand)
	session.commit()

	flash(brand.name+" successfully deleted!!")
	return redirect(url_for('adminpage'))
Пример #4
0
def delete_users(id):
    session = db.getSession(engine)
    usuarios = session.query(entities.User).filter(entities.User.id == id)
    for esteUsuario in usuarios:
        session.delete(esteUsuario)
    session.commit()
    return "Deleted User"
Пример #5
0
def delete_message(id):
    session = db.getSession(engine)
    message = session.query(
        entities.Message).filter(entities.Message.id == id).one()
    session.delete(message)
    session.commit()
    return redirect(url_for('messages'))
Пример #6
0
def delete_msg(id):
    session = db.getSession(engine)
    messages = session.query(entities.msg).filter(entities.msg.id == id)
    for msg in messages:
        session.delete(msg)
    session.commit()
    return "El mensaje ha sido eliminado"
Пример #7
0
	def delete(self):
		if not g.get('admin'):
			msg = {
				"i_status": 0,
				"err_code": 11,
				"msg": "Not login."
			}
			return msg
		args = class_delete_parser.parse_args(strict=True)
		session = g.Session()
		try:
			Class2Del = session.query(db.Classes).filter(db.Classes.id == args.get('class_id')).one()
			session.delete(Class2Del)
			session.commit()
			msg = {
				"i_status": 1,
				"err_code": -1,
				"msg": ""
			}
		except Exception as e:
			l.error(e)
			session.rollback()
			msg = {
				"i_status": 0,
				"err_code": 18,
				"msg": "Class delete err"
			}
		finally:
			session.close()

		return msg
Пример #8
0
def delete_message():
    id = request.form['key']
    session = db.getSession(engine)
    message = session.query(entities.Message).filter(entities.Message.id == id).one()
    session.delete(message)
    session.commit()
    return "Deleted Message"
Пример #9
0
def delete_message(id):
    session = db.getSession(engine)
    message = session.query(entities.Message).filter(entities.Message.id == id)
    for x in message:
        session.delete(x)
    session.commit()
    return "MESSAGE DELETED"
Пример #10
0
def remove_msj(id):
    session = db.getSession(engine)
    msjs = session.query(entities.Msj).filter(entities.Msj.id == id)
    for m in msjs:
        session.delete(m)
    session.commit()
    return "DELETED"
def delete_viajeroDevExtream():
    id = request.form['key']
    session = db.getSession(engine)
    viajero = session.query(entities.Viajero).filter(entities.Viajero.id == id).one()
    session.delete(viajero)
    session.commit()
    return "Deleted Viajero"
Пример #12
0
	def _case_removed(self, engine_case):
		session = db.Session()
		case = session.query(Case).filter(Case.engine_name == engine_case.name).first()
		if case is not None:
			self.case_removed.send(case, server=self, logger=self.logger)
			session.delete(case)
			session.commit()
Пример #13
0
 def delete(self):
     if not self.data.filename is None:
         path = os.path.join(UPLOAD_FOLDER, 'recipes', str(g.user.id),
                             self.data.filename)
         self.uploader.delete("/" + path)
     with session_scope() as session:
         session.delete(self.data)
def delete_experiencia():
    id = request.form['key']
    session = db.getSession(engine)
    experiencia = session.query(entities.Experiencia).filter(entities.Experiencia.id == id).one()
    session.delete(experiencia)
    session.commit()
    return "Deleted Experiencia"
Пример #15
0
 def delete(self, dish_id):
     abort_if_users_not_found(dish_id)
     session = db_session.create_session()
     dish = session.query(Dish).get(dish_id)
     session.delete(dish)
     session.commit()
     return jsonify({'success': 'OK'})
Пример #16
0
def delete_chip():
    id = request.form['key']
    session = db.getSession(engine)
    chip = session.query(entities.Chips).filter(entities.Chips.id == id).one()
    session.delete(chip)
    session.commit()
    return "Deleted Chip"
Пример #17
0
def delete():
    repo_id = request.args.get('repo_id', '')
    build_id = request.args.get('build_id', '')
    user_id = request.args.get('user_id', '')

    session = request.db_session
    delete_target = None
    if build_id:
        delete_target = session.query(Build).get(build_id)
        if not request.user.can_manage:
            return abort(403)
    elif repo_id:
        delete_target = session.query(Repository).get(repo_id)
        if not request.user.can_manage:
            return abort(403)
    elif user_id:
        delete_target = session.query(User).get(user_id)
        if delete_target and delete_target.id != request.user.id and not request.user.can_manage:
            return abort(403)

    if not delete_target:
        return abort(404)

    try:
        session.delete(delete_target)
        session.commit()
    except Build.CanNotDelete as exc:
        session.rollback()
        utils.flash(str(exc))
        referer = request.headers.get('Referer', url_for('dashboard'))
        return redirect(referer)

    utils.flash('{} deleted'.format(type(delete_target).__name__))
    return redirect(url_for('dashboard'))
Пример #18
0
def delete():
  repo_id = request.args.get('repo_id', '')
  build_id = request.args.get('build_id', '')
  user_id = request.args.get('user_id', '')

  session = request.db_session
  delete_target = None
  if build_id:
    delete_target = session.query(Build).get(build_id)
    if not request.user.can_manage:
      return abort(403)
  elif repo_id:
    delete_target = session.query(Repository).get(repo_id)
    if not request.user.can_manage:
      return abort(403)
  elif user_id:
    delete_target = session.query(User).get(user_id)
    if delete_target and delete_target.id != request.user.id and not request.user.can_manage:
      return abort(403)

  if not delete_target:
    return abort(404)

  try:
    session.delete(delete_target)
    session.commit()
  except Build.CanNotDelete as exc:
    session.rollback()
    utils.flash(str(exc))
    referer = request.headers.get('Referer', url_for('dashboard'))
    return redirect(referer)

  utils.flash('{} deleted'.format(type(delete_target).__name__))
  return redirect(url_for('dashboard'))
Пример #19
0
 def all_delete():
     cart = session.query(Cart).filter(Cart.id == current_user.id).first()
     cart_products = session.query(Cart_Product).filter(Cart_Product.cart_id == cart.id)
     for product in cart_products:
         session.delete(product)
         session.commit()
     return redirect('/thanks')
def delete_event():
    id = request.args.get("id") # event ID
    user_id = request.args.get("user_id")
    e = session.query(Event).get(id)
    session.delete(e)
    session.commit()
    return redirect("/student-life?id=" + user_id)
def admin_delete_user(user_id):
    if g.user.id != 1:
        return redirect('/')
    session = db_session.create_session()
    user = session.query(User).filter(User.id == user_id).first()
    # проверяем, существует ли пользователь
    if user:
        # получаем список работ пользователя
        works = session.query(Work).filter(Work.user_id == user_id)
        for work in works:
            # удаляем записи о фотографиях и фотографии с сервера
            photos = session.query(Photo).filter(Photo.work_id == work.id)
            for photo in photos:
                if os.path.exists("static/photos/" + photo.filename):
                    os.remove("static/photos/" + photo.filename)
                if os.path.exists("static/photos/tumb_" + photo.filename):
                    os.remove("static/photos/tumb_" + photo.filename)
            session.query(Photo).filter(Photo.work_id == work.id).delete()
            # удаляем записи о голосах за работу
            session.query(Voite).filter(Voite.work_id == work.id).delete()
            # удаляем запись о работе
            session.delete(work)
        # удаляем пользователя
        session.delete(user)
        session.commit()
        return redirect('/admin/users')
    else:
        return redirect('/admin/users')
Пример #22
0
def set_garbage():
    j = sanitize_set_garbage(request.get_json(force=True,silent=True))
    if not j:
        example = json.dumps({ "id":"123",
            "price_bonus":12.34 })
        return json.dumps({ 'error': ('provide a valid json body! example: %s' % (example,)) }), 400

    session = db.Session()

    print "bla"

    tid = j['id']
    try:
        task = session.query(db.OpenTask).filter(db.OpenTask.id == tid).one()
    except NoResultFound:
        session.close()
        return json.dumps({ 'error': 'id does not exists' }), 400
    except MultipleResultsFound:
        session.close()
        return json.dumps({ 'error': 'more than one result found' }), 400


    print(task.id)

    session.delete(task)


    session.commit()

    result = { 'error': None, 'success': True }, 200

    return json.dumps(result)    
def delete_group(id):
    session = db.getSession(engine)
    group = session_db.query(
        entities.Group).filter(entities.Group.id == id).one()
    session.delete(group)
    session.commit()
    return "Deleted Group"
def apaga_contato(id):
    try:
        contato = session.query(Contatos).filter_by(id=id).first()
        session.delete(contato)
        session.commit()
    finally:
        pass
Пример #25
0
def delete_plates():
    id = request.form['key']
    session = db.getSession(engine)
    plate = session.query(entities.Plate).filter(entities.Plate.id == id).one()
    session.delete(plate)
    session.commit()
    return "Deleted Plate"
def delete_work(work_id):
    session = db_session.create_session()
    work = session.query(Work).filter(Work.id == work_id).first()
    # проверяем, существует ли работа и принадлежит ли она пользователю
    if work and work.user_id == g.user.id:
        form = DeleteForm()
        if request.method == 'POST' and form.validate_on_submit():
            # удаляем записи о фотографиях и фотографии с сервера
            photos = session.query(Photo).filter(Photo.work_id == work_id)
            for photo in photos:
                if os.path.exists("static/photos/" + photo.filename):
                    os.remove("static/photos/" + photo.filename)
                if os.path.exists("static/photos/tumb_" + photo.filename):
                    os.remove("static/photos/tumb_" + photo.filename)
            session.query(Photo).filter(Photo.work_id == work_id).delete()
            # удаляем записи о голосах за работу
            session.query(Voite).filter(Voite.work_id == work_id).delete()
            # удаляем запись о работе
            session.delete(work)
            session.commit()
            return redirect('/user')
        return render_template('delete_work.html',
                               title='Удаление работы',
                               form=form,
                               work=work)
    else:
        return render_template('delete_work.html', title='Работа не найдена')
Пример #27
0
def set_garbage():
    j = sanitize_set_garbage(request.get_json(force=True,silent=True))
    if not j:
        example = json.dumps({ "id":"123",
            "price_bonus":12.34 })
        return json.dumps({ 'error': ('provide a valid json body! example: %s' % (example,)) }), 400

    with db.session_scope() as session:
        tid = j['id']
        try:
            task = session.query(db.OpenTask).filter(db.OpenTask.id == tid).one()
        except NoResultFound:
            return json.dumps({ 'error': 'id does not exists' }), 400
        except MultipleResultsFound:
            return json.dumps({ 'error': 'more than one result found' }), 400

        logger.info("set garbage called with task id %d", task.id)

        session.delete(task)

        session.commit()

        result = { 'error': None, 'success': True }, 200

        return json.dumps(result)    
Пример #28
0
def delete_users():
    id = request.form['key']
    session = db.getSession(engine)
    messages = session.query(entities.User).filter(entities.User.id == id).one()
    session.delete(messages)
    session.commit()
    return "Deleted User"
Пример #29
0
 def delete(self, user_id):
     abort_if_users_not_found(user_id)
     session = db_session.create_session()
     user = session.query(User).get(user_id)
     session.delete(user)
     session.commit()
     return jsonify({'success': 'OK'})
Пример #30
0
def deleteItem(category_name, item_id):
    if 'username' not in login_session:
        return redirect('/login')
    categories = session.query(Category)
    itemToDelete = session.query(CategoryItem).filter_by(id=item_id).one()
    if itemToDelete.user_id != login_session['user_id']:
        flash('You are not authorized to delete {}. '
              'Please create your own Item in order to edit'
              .format(editItem.name))
        return redirect(url_for('showCatalog'))
#        return "<script>function myFunction()"\
#               "{alert('You are not  authorized to edit this Item."\
#               "Please create your own Item in order to edit.'); }"\
#               "</script><body onload='myFunction()''>"
    if request.method == 'POST':
        session.delete(itemToDelete)
        session.commit()
        flash("Item Successfully Removed")
        return redirect(
            url_for(
                'showCategoryItem',
                category_name=category_name))
    else:
        return render_template(
            'deleteItem.html',
            category=categories,
            category_name=category_name,
            item=itemToDelete)
Пример #31
0
def delete_user(id):
    #id = request.form['key']
    session = db.getSession(engine)
    user = session.query(entities.User).filter(entities.User.id == id).one()
    session.delete(user)
    session.commit()
    return "Deleted User"
Пример #32
0
def delete_experiencia_id(id):
    session = db.getSession(engine)
    experiencia = session.query(
        entities.Experiencia).filter(entities.Experiencia.id == id).one()
    session.delete(experiencia)
    session.commit()
    return "Deleted Experiencia"
Пример #33
0
def deleteProduct(category_id, product_id):
    """Delete a product in one specific category."""
    if 'username' not in login_session:
        return redirect('/login')
    categories = session.query(Category).order_by(asc(Category.name))
    category = session.query(Category).filter_by(id=category_id).one()
    #    itemToDelete = session.query(Product).filter_by(id=product_id).one()
    if login_session['user_id'] != category.user_id:
        flash('You are not permitted to delete this product. '
              'Please create your own product to delete.')
        return redirect(
            url_for('showList', category_id=category_id,
                    categories=categories))
    itemToDelete = session.query(Product).filter_by(id=product_id).one()
    if request.method == 'POST':
        session.delete(itemToDelete)
        session.commit()
        flash('Successfully Deleted')
        return redirect(
            url_for('showList', category_id=category_id,
                    categories=categories))
    else:
        return render_template('deleteproduct.html',
                               item=itemToDelete,
                               categories=categories)
Пример #34
0
def save_people_to_article() -> Any:

    (articleid, people_ids) = get_select_ids(request.form)

    session = new_session()

    existing_people = session.query(ArticlePerson)\
                             .filter(ArticlePerson.article_id == articleid)\
                             .all()

    (to_add,
     to_remove) = get_join_changes([x.person_id for x in existing_people],
                                   [int(x['id']) for x in people_ids])

    for id in to_remove:
        aa = session.query(ArticlePerson)\
                    .filter(ArticlePerson.article_id == articleid, ArticlePerson.person_id == id)\
                    .first()
        session.delete(aa)
    for id in to_add:
        aa = ArticlePerson(article_id=articleid, person_id=id)
        session.add(aa)

    session.commit()

    msg = 'Tallennus onnistui'
    category = 'success'
    resp = {'feedback': msg, 'category': category}
    return make_response(jsonify(resp), 200)
Пример #35
0
def remove_user(id):
    session = db.getSession(engine)
    users = session.query(entities.User).filter(entities.User.id == id)
    for user in users:
        session.delete(user)
    session.commit()
    return "DELETED"
Пример #36
0
def save_tags_to_article() -> Any:

    (articleid, tag_ids) = get_select_ids(request.form)

    session = new_session()
    tag_ids = create_new_tags(session, tag_ids)

    existing_tags = session.query(ArticleTag)\
        .filter(ArticleTag.article_id == articleid)\
        .all()

    (to_add, to_remove) = get_join_changes([x.tag_id for x in existing_tags],
                                           [int(x['id']) for x in tag_ids])

    for id in to_remove:
        at = session.query(ArticleTag)\
                    .filter(ArticleTag.article_id == articleid, ArticleTag.tag_id == id)\
                    .first()
        session.delete(at)
    for id in to_add:
        at = ArticleTag(article_id=articleid, tag_id=id)
        session.add(at)

    session.commit()

    msg = 'Tallennus onnistui'
    category = 'success'
    resp = {'feedback': msg, 'category': category}
    return make_response(jsonify(resp), 200)
Пример #37
0
def clear_complete():
    session = Session()
    if request.method == 'POST':
        for task in session.query(Task).filter_by(is_complete=True).all():
            if (task.is_complete):
                session.delete(task)
        session.commit()
    return redirect('/')
Пример #38
0
def material_delete(part_name):
    session = db.session()
    part = Material.query.filter_by(part=part_name).first()
    if part is not None:
        if path.exists(dir + '/app/static/img/material/%s_%s.png' % (part.part, part.vendor)):
            remove_file(dir + '/app/static/img/material/%s_%s.png' % (part.part, part.vendor))
        session.delete(part)
        session.commit()
    return redirect(url_for("material_list"))
Пример #39
0
    def test_write_bill_committees(self):
        query = session.query(bill_committee).all()
        startSize = len(query)

        session.add(bill_committee(bill_id=7, committee_id=5))
        res = session.query(bill_committee).all()
        endSize = len(res)

        self.assertEqual(startSize + 1, endSize)
        query = session.query(bill_committee).filter(bill_committee.bill_id == 7).first()
        session.delete(query)
Пример #40
0
    def test_write_votes(self):
        query = session.query(vote).all()
        startSize = len(query)

        session.add(vote(legislator_id=1, bill_id=2))
        res = session.query(vote).all()
        endSize = len(res)

        self.assertEqual(startSize + 1, endSize)
        query = session.query(vote).filter(vote.legislator_id == 1).first()
        session.delete(query)
Пример #41
0
def send_epub_to_readmill(filepath):
  url = '%s/me/library?client_id=%s' % (READMILL_API_ROOT, READMILL_CLIENT_ID)
  headers = {'Authorization': 'OAuth %s' % session['access_token']}
  files = {'library_item[asset]': open(filepath, 'rb')}

  response = requests.post(url, headers=headers, files=files)

  if response.status_code == 201:
    return response.json()
  elif response.status_code == 401:
    session.delete('access_token')
  else:
    app.logger.debug('Failed to send epub, server responded with: %s and body: %s' % (response.status_code, response.json()))
Пример #42
0
    def test_delete_bill_row2(self):
        session.add(bill(name="delete2"))
        session.commit()

        query = session.query(bill).filter(bill.name == "delete2").first()

        assert query != None

        session.delete(query)
        session.commit()

        toRemove = session.query(bill).filter(bill.name == "delete2").first()
        assert toRemove == None
Пример #43
0
    def test_delete_committee_members_row(self):
        session.add(committee_member(legislator_id=10, committee_id=10))
        session.commit()

        query = session.query(committee_member).filter(committee_member.legislator_id == 10).first()

        assert query != None

        session.delete(query)
        session.commit()

        toRemove = session.query(committee_member).filter(committee_member.legislator_id == 10).first()
        assert toRemove == None
Пример #44
0
    def test_delete_bill_committees_row(self):
        session.add(bill_committee(bill_id=9, committee_id=10))
        session.commit()

        query = session.query(bill_committee).filter(bill_committee.bill_id == 9).first()

        assert query != None

        session.delete(query)
        session.commit()

        toRemove = session.query(bill_committee).filter(bill_committee.bill_id == 9).first()
        assert toRemove == None
Пример #45
0
    def test_delete_votes_row(self):
        session.add(vote(legislator_id=5, bill_id=6))
        session.commit()

        query = session.query(vote).filter(vote.legislator_id == 5).first()

        assert query != None

        session.delete(query)
        session.commit()

        toRemove = session.query(vote).filter(vote.legislator_id == 5).first()
        assert toRemove == None
Пример #46
0
	def remove_case(self, user, case):
		# The case will be remove from the db when the case remove signal arrives
		case.removed = True
		session = inspect(case).session
		session.commit() # FIXME sure to do the commit here ?

		if self.engine.exists_case(case.engine_name):
			self.engine.remove_case(case.engine_name)
		else:
			self.logger.debug("No engine case available: {}".format(case.engine_name))
			self.case_removed.send(case)
			session.delete(case)
			session.commit()
Пример #47
0
def deleteItem(item):
	"""This page will be for deleting the selected item"""
	login_already=current_user.is_authenticated()
	if login_already:
		if request.method == "POST":
			# This post request is submited automatically in delete.html for csrf protection.
			if request.form['delete_it'] == "yes":
				i = session.query(Item).filter_by(id=item).one()
				session.delete(i)
				session.commit()
				return redirect("/")
		return render_template("delete.html")
	else:
		return redirect("/")
Пример #48
0
    def test_delete_committee_row(self):

        session.add(committee(name="delete"))
        session.commit()

        query = session.query(committee).filter(committee.name == "delete").first()

        assert query != None

        session.delete(query)
        session.commit()

        toRemove = session.query(committee).filter(committee.name == "delete").first()
        assert toRemove == None
Пример #49
0
    def test_delete_legislators_row(self):

        session.add(legislator(last_name="delete"))
        session.commit()

        query = session.query(legislator).filter(legislator.last_name == "delete").first()

        assert query != None

        session.delete(query)
        session.commit()

        toRemove = session.query(legislator).filter(legislator.last_name == "delete").first()
        assert toRemove == None
Пример #50
0
    def test_read_votes(self):
        session.add(vote(legislator_id=3, bill_id=4))
        session.commit()

        query = session.query(vote).all()
        found = False

        for x in query:
            if x.legislator_id == 3:
                found = True

        assert found
        query = session.query(vote).filter(vote.legislator_id == 3).first()
        session.delete(query)
Пример #51
0
    def test_read_bill_committees(self):
        session.add(bill_committee(bill_id=8, committee_id=9))
        session.commit()

        query = session.query(bill_committee).all()
        found = False

        for x in query:
            if x.bill_id == 8:
                found = True

        assert found
        query = session.query(bill_committee).filter(bill_committee.bill_id == 8).first()
        session.delete(query)
Пример #52
0
    def test_write_committee_members(self):
        query = session.query(committee_member).all()
        startSize = len(query)

        session.add(committee_member(legislator_id=8, committee_id=8))
        res = session.query(committee_member).all()
        session.commit()

        query = session.query(committee_member).all()
        endSize = len(query)

        self.assertEqual(startSize + 1, endSize)
        query = session.query(committee_member).filter(committee_member.legislator_id == 8).first()
        session.delete(query)
Пример #53
0
    def test_read_commmittee_members(self):

        session.add(committee_member(legislator_id=9, committee_id=9))
        session.commit()

        query = session.query(committee_member).all()
        found = False

        for x in query:
            if x.legislator_id == 9:
                found = True

        assert found
        query = session.query(committee_member).filter(committee_member.legislator_id == 9).first()
        session.delete(query)
Пример #54
0
def delete_category(category_name):
	# Allowes logged user to delete a category they own

	category =  get_category_with_name(category_name)
	items = category.items

	if request.method == "GET":
		return render_template("delete_category.html", category = category)

	# Processing Post Request

	session.delete(category)
	session.commit()
	flash("Category {0}, and all items inside were successfully deleted".format(category.name))

	return redirect("/")
Пример #55
0
def delete_item(category_name, item_name):
	# Allowes logged user to delete an item they own

	item = get_item_with_name(item_name)
	category = item.category

	if request.method == "GET":
		return render_template("delete_item.html", category = category, item = item)

	# Processing Post Request
	name = request.form.get("name")

	session.delete(item)
	session.commit()
	flash("Item {0} was successfully deleted".format(item.name))

	return redirect("/catalog/{0}".format(category.name))
Пример #56
0
def changeItem():
    quantity = request.form['quantity']
    productvariant_id = request.form['id']

    cart_id = session.get('cart_id',None)
    if cart_id is None:
        cart = Cart()
        cart.token = uuid.uuid4().hex
        db.session.add(cart)
        db.session.commit()
        cart_id=cart.id
        session['cart_id']=cart_id
    else:        
        cart = Cart.query.get(cart_id)

    for i in cart.cartlines:
        if i.productvariant_id == productvariant_id:
            if quantity==0:
                session.delete(i)
                session.commit()
            else:
                i.quantity = quantity
                session.update(i)
                session.commit()
    cart_data = {"token": cart.token,
                 "items": [{"id":i.productvariant.mainproduct.id,
                            "title":i.productvariant.mainproduct.title,
                            "description":i.productvariant.mainproduct.description,
                            "image": i.productvariant.mainproduct.image,                          
                            "variant_id" : i.productvariant.id,
                            "variant_title" : i.productvariant.title,
                            "variant_description": i.productvariant.description,
                            "variant_sku" : i.productvariant.sku,
                            "variant_price": i.productvariant.price,

                            "line_price" : i.quantity * i.productvariant.price,
                            "price" : i.productvariant.price,
                            "quantity" :i.quantity
                            } for i in cart.cartlines],
                 "total_price" : sum([i.productvariant.price*i.productvariant.quantity for i in cart.cartlines]),
                 "item_count" : len(cart.cartlines)
                 }

    current_app.logger.debug('Shopping remove item')
    return jsonify(cart_data)
Пример #57
0
def index():
    session = dbsession()
    if request.method == 'POST':
        action = request.form.get('action')

        for id in [int(str_id) for str_id in request.form.getlist('requests')]:
            req = session.query(Request).filter(Request.request_id==id).one()
            if action == 'resubmit':
                if not submit_request(req):
                    req.next_check = datetime.utcnow() + \
                        timedelta(minutes=req.next_interval)
                    req.next_interval = req.next_interval * 2
                    session.add(req)

            elif action == 'delete':
                session.delete(req)


    reqs = session.query(Request).all()
    session.commit()
    return render_template('index.jinja', reqs=reqs, num_reqs=len(reqs))
Пример #58
0
def logout():
    session.delete()
    return redirect(url_for('login'))
Пример #59
0
def logout():
    flash("Successfully logged out.")
    session.delete()
    return redirect(url_for('index'))
Пример #60
0
def revoke_access():
    access = db_session.query(Viewer). \
        filter_by(patient_id=patient_id, provider_id=provider_id). \
        all()
    session.delete(access)