Exemple #1
0
def deleting_list(msg):
    user = User.get_by_id(msg.chat.id)
    if msg.text.startswith("🔙 "):
        bot.send_message(msg.chat.id,
                         _("Canceled"),
                         reply_markup=mps.main_mp(user.id))
        return
    try:
        list_name = msg.text[4:]
        list_ = List.get((List.name == list_name) & (List.owner == user))
    except (IndexError, DoesNotExist):
        bot.send_message(
            msg.chat.id,
            _("This list doesn't exist, choose from keyboard below"),
            reply_markup=mps.delete_list_mp(user.id))
        bot.register_next_step_handler_by_chat_id(user.id, deleting_list)
        return
    if list_ == list_.subscribed_by:
        for sub in List.select().where(List.subscribed_by == list_):
            bot.delete_message(sub.owner.id, sub.last_message_id)
            sub.delete_instance()
            bot.send_message(sub.owner.id,
                             _("List _%s_ was deleted") % sub.name,
                             reply_markup=mps.main_mp(sub.owner.id),
                             parse_mode='markdown',
                             disable_notification=True)
    else:
        bot.delete_message(msg.chat.id, list_.last_message_id)
        list_.delete_instance()
        bot.send_message(
            msg.chat.id,
            _("You were successfully unsubscribed from list _%s_ ") %
            list_name,
            reply_markup=mps.main_mp(msg.chat.id),
            parse_mode='markdown')
Exemple #2
0
def comments_list(movieid):
    movie_id = int(movieid)
    from models import List
    query = List.select(List.comment).where(List.movie_id == movie_id)
    for list in query:
        print(list.comment)
    return redirect(url_for('movie', movieid=movieid, query=query))
Exemple #3
0
def delete_list_mp(chat_id):
    lists = List.select().where(List.owner == chat_id)

    mp = ReplyKeyboardMarkup(row_width=1)
    mp.add(*(KeyboardButton("❌ 📝 " + list_.name) for list_ in lists))
    mp.add(KeyboardButton(_("🔙 Back")))

    return mp
Exemple #4
0
def share_table(q: types.InlineQuery):
    lists = List.select().where(List.owner == q.from_user.id)
    bot.answer_inline_query(q.id,
                            mps.inline_share_list(lists, me),
                            cache_time=5,
                            is_personal=True,
                            switch_pm_text=_("➕ Create list ➕"),
                            switch_pm_parameter='createlist')
Exemple #5
0
def commit_deleting(c):
    dot = c.data.find('.')
    list_id = int(c.data[3:dot])
    list_ = List.get_by_id(list_id)

    spt_s = c.data[dot + 1:]
    spotted = [int(i) for i in spt_s.split(',')]

    Item.delete().where(Item.id.in_(spotted)).execute()
    for sub in List.select().where(List.subscribed_by == list_.subscribed_by):
        bot.edit_message_reply_markup(sub.owner.id,
                                      sub.last_message_id,
                                      reply_markup=mps.list_mp(sub.id))
Exemple #6
0
def main_mp(chat_id):
    lists = List.select().where(List.owner == chat_id)

    mp = ReplyKeyboardMarkup(row_width=1)
    if len(lists) > 0:
        mp.row(KeyboardButton(_("➕ Create list ➕")),
               KeyboardButton(_("✖ Delete list ✖")))
    else:
        mp.row(KeyboardButton(_("➕ Create list ➕")))
    for list_ in lists:
        if list_ != list_.subscribed_by:
            mp.add(KeyboardButton("🔗 📝 " + list_.name))
        else:
            mp.add(KeyboardButton("📝 " + list_.name))
    mp.add(KeyboardButton(_("⚙️ Settings ⚙️")))
    if chat_id in const.admins:
        mp.add("📢 Рассылка")
    return mp
Exemple #7
0
def movie(movieid=None):
    from models import List
    form = forms.CommentForm()
    if movieid and request.method == 'GET':
        movie_id = int(movieid)
        from models import List, User
        query = (List.select(List.comment, User.username).join(User).where(
            User.id == List.user
            and List.movie_id == movie_id)).where(fn.length(List.comment) > 0)
        return render_template('movie.html',
                               form=form,
                               movieid=movieid,
                               query=query)
    elif movieid and request.method == 'POST':
        comment = models.List.select().where(
            models.List.user == current_user,
            models.List.movie_id == movieid).get()
        comment.comment = form.comment.datas
Exemple #8
0
def update_list(c):
    dot = c.data.find('.')
    list_id = int(c.data[8:dot])
    list_ = List.get_by_id(list_id)
    if c.data[dot + 1:]:
        item_id = int(c.data[dot + 1:])
        item = Item.get_by_id(item_id)
        item.tag = not item.tag
        item.save()
        for sub in List.select().where(
                List.subscribed_by == list_.subscribed_by):
            bot.edit_message_reply_markup(sub.owner.id,
                                          sub.last_message_id,
                                          reply_markup=mps.list_mp(list_id))
        bot.answer_callback_query(c.id)
    else:
        bot.edit_message_reply_markup(c.message.chat.id,
                                      c.message.message_id,
                                      reply_markup=mps.list_mp(list_id))
Exemple #9
0
def index(password):
    print >> sys.stderr, "within index"
    try:
        if password == PASSWORD:
            print >> sys.stderr, "within try"
            sellerList = Seller.select()
            smsList = SMS.select()
            numberList = Number.select()
            l = List.select()
            marketList = Market.select()
            lrList = ListRelationship.select()
            outboxList = Outbox.select()
            return render_template("index.html", title = 'TABLES', sellerList = sellerList, smsList = smsList, l = l, marketList = marketList)
            #return 'hello world'
        else:
            print >> sys.stderr, "wrong password"
    except:
        print >> sys.stderr, "within except"
        print >> sys.stderr, str(sys.exc_info()[0]) # These write the nature of the error
        print >> sys.stderr, str(sys.exc_info()[1])
        statement = 'An exception has Occured'+ str(sys.exc_type) + '[' + str(sys.exc_value) + ']'
        return statement
Exemple #10
0
def get_Mini_Sellers_ListNames(seller):
    sellersListNames = []
    for l in List.select().where(List.seller == seller):
        sellersListNames.append(l.name)
    return sellersListNames
Exemple #11
0
def check_Mini_Sellers_ListName_Exists(seller, name):
    for l in List.select():
        if l.seller == seller and l.name == name:
            print 'seller already created this list!'
            return True
Exemple #12
0
def check_List_Exists(listName):
    for l in List.select():
        if listName == List.name:
            print 'this list exists!'
            return True
Exemple #13
0
        item.tag = not item.tag
        item.save()
        for sub in List.select().where(
                List.subscribed_by == list_.subscribed_by):
            bot.edit_message_reply_markup(sub.owner.id,
                                          sub.last_message_id,
                                          reply_markup=mps.list_mp(list_id))
        bot.answer_callback_query(c.id)
    else:
        bot.edit_message_reply_markup(c.message.chat.id,
                                      c.message.message_id,
                                      reply_markup=mps.list_mp(list_id))


# # # # # # Callback query # # # # # # #
@bot.inline_handler(func=lambda q: List.select().where(
    (List.owner == q.from_user.id) & (List.name == q.query)))
def share_table(q: types.InlineQuery):
    list_ = List.get((List.owner == q.from_user.id) & (List.name == q.query))
    bot.answer_inline_query(q.id,
                            mps.inline_share_list((list_, ), me),
                            cache_time=5,
                            is_personal=True,
                            switch_pm_text=_("➕ Create list ➕"),
                            switch_pm_parameter='createlist')


@bot.inline_handler(func=lambda q: True)
def share_table(q: types.InlineQuery):
    lists = List.select().where(List.owner == q.from_user.id)
    bot.answer_inline_query(q.id,
                            mps.inline_share_list(lists, me),
Exemple #14
0
import datetime

from models import Board, List, Task

highest_order = Task.select().where(Task.belongs_to_list == 1).order_by(Task.task_order.desc()).get()

new_task = Task(
    belongs_to_list=List.select().where(List.name == "Important List"),
    task_name="Learn Rails",
    task_description="I am trying to learn rails so I can build complex apps in the future and also my own api someday.",
    task_order=(highest_order.task_order + 1),
)
new_task.save()
Exemple #15
0
import datetime

from models import Board, List, Task

highest_order = Task.select().where(Task.belongs_to_list == 1).order_by(
    Task.task_order.desc()).get()

new_task = Task(
    belongs_to_list=List.select().where(List.name == "Important List"),
    task_name="Learn Rails",
    task_description=
    "I am trying to learn rails so I can build complex apps in the future and also my own api someday.",
    task_order=(highest_order.task_order + 1))
new_task.save()