예제 #1
0
def index():
    belum_setor = get_belum_setor()
    sudah_setor = select(s for s in Santri if s not in belum_setor)
    setoran = select(s for s in Setoran).order_by(desc(Setoran.timestamp))[:5]
    return render_template("front_page/index.html",
                           sudah_setor=sudah_setor,
                           belum_setor=get_belum_setor(),
                           setoran=setoran)
예제 #2
0
    def test_yang_belum_murojaah_tambah_sama_sekali_hari_ini(self):
        """ditest ini dan yang berikutnya, akan menambahkan setoran dihari yang kemarin dan dia sudah tidak ada tanggungan dihari kemarin.

        result adalah hanya santri yang belum setor hari ini..."""
        raffi = get(santri for santri in Santri if santri.nama == 'raffi')
        iqbal = get(santri for santri in Santri if santri.nama == 'iqbal')
        now = datetime.now()
        yesterday = now - timedelta(days=1)
        Setoran(start='1/1',
                end='1/3',
                jenis='tambah',
                lulus=True,
                timestamp=yesterday,
                santri=raffi)
        Setoran(start='1/1',
                end='1/3',
                jenis='murojaah',
                lulus=True,
                timestamp=yesterday,
                santri=raffi)
        Setoran(start='1/1',
                end='1/2',
                jenis='tambah',
                lulus=False,
                timestamp=datetime.now(),
                santri=iqbal)
        Santri(nama='ihfazh')
        blm = get_belum_setor()
        self.assertEqual(count(blm), 2)
        self.assertIn('raffi', [santri.nama for santri in blm])
예제 #3
0
def process_persetujuan_setor(bot, update):
    message = update.message.text
    chat_id = update.message.chat_id
    data_setoran = CONTEXT[chat_id]['setoran']

    if chat_id in ADMIN_IDS:
        if message == "✔ Simpan":
            # process simpan
            # with db_session:
            nama = get(s for s in Santri if s.nama == data_setoran['santri'])
            data_setoran['santri'] = nama
            Setoran(**data_setoran)
            commit()

            belum_setor = get_belum_setor()
            sudah_setor = select(santri for santri in Santri
                                 if santri not in belum_setor)

            reply = "Summary data setoran\n\n"
            reply += "Sudah setor: \n"
            reply += "\n".join(s.nama for s in sudah_setor)
            reply += "\n\n\n"
            reply += "Belum setor: \n"
            reply += "\n".join(s.nama for s in belum_setor)

            update.message.reply_text(
                "Data yang anda masukkan telah kami simpan\n" + reply,
                reply_markup=ReplyKeyboardMarkup(reply_start,
                                                 one_time_keyboard=True,
                                                 resize_keyboard=True))

            del data_setoran

            return START

        elif message == "✖ Jangan":

            update.message.reply_text(
                "Data yang anda masukkan akan kami delete",
                reply_markup=ReplyKeyboardMarkup(reply_start,
                                                 one_time_keyboard=True,
                                                 resize_keyboard=True))

            del data_setoran

            return START
        else:

            update.message.reply_text("Maaf, masukan salah",
                                      reply_markup=ReplyKeyboardMarkup(
                                          reply_persetujuan,
                                          one_time_keyboard=True,
                                          resize_keyboard=True))

            return PROCESS_PERSETUJUAN_SETORAN
    else:
        update.massage.reply_text("⛔⛔⛔ Maaf, anda tidak terdaftar ⛔⛔⛔")
 def test_index_has_context(self):
     """testing index, has this context:
             - sudah_setor
             - belum_setor
             - setoran, orderby tanggal, terbaru
     """
     self.client.get("/")
     sudah_setor = self.get_context_variable("sudah_setor")
     belum_setor = self.get_context_variable("belum_setor")
     setoran = self.get_context_variable("setoran")
     belum_setor_from_db = get_belum_setor()
     sudah_setor_from_db = select(s for s in Santri
                                  if s not in belum_setor_from_db)
     setoran_from_db = select(s for s in Setoran).order_by(
         desc(Setoran.timestamp))[:5]
     self.assertEqual(list(belum_setor), list(belum_setor_from_db))
     self.assertEqual(list(sudah_setor), list(sudah_setor_from_db))
     self.assertEqual(list(setoran), list(setoran_from_db))
예제 #5
0
def process_belum(bot, update):

    message = update.message.text
    chat_id = update.message.chat_id

    if chat_id in ADMIN_IDS:
        if message == "Setoran":
            santri = get_belum_setor()
            body = "Daftar Santri belum setor (%s)" % count(santri)
            body += "\n\n"
            santri_ = [s.nama for s in santri]
            body += "\n".join(santri_)
            body += "\n"

            update.message.reply_text(body,
                                      reply_markup=ReplyKeyboardMarkup(
                                          reply_start,
                                          one_time_keyboard=True,
                                          resize_keyboard=True))

            return START
        elif message == "♻ Murojaah":
            santri = get_belum_murojaah()
            body = "Daftar santri belum murojaah (%s)" % count(santri)
            body += "\n\n"
            santri_ = [s.nama for s in santri]
            body += "\n".join(santri_)
            body += "\n"

            update.message.reply_text(body,
                                      reply_markup=ReplyKeyboardMarkup(
                                          reply_start,
                                          one_time_keyboard=True,
                                          resize_keyboard=True))
            return START
        elif message == "➕ Tambah Baru":
            santri = get_belum_tambah()
            body = "Daftar santri belum tambah (%s)" % count(santri)
            body += "\n\n"
            body += "\n".join(s.nama for s in santri)
            body += "\n"

            update.message.reply_text(body,
                                      reply_markup=ReplyKeyboardMarkup(
                                          reply_start,
                                          one_time_keyboard=True,
                                          resize_keyboard=True))

            return START

        elif message == "Murojaah sudah, harus ulang":
            santri = get_sudah_murojaah_harus_ulang()
            body = "Daftar santri sudah murojaah belum lancar (%s)" % count(
                santri)
            body += "\n\n"
            body += "\n".join(s.nama for s in santri)
            body += "\n"

            update.message.reply_text(body,
                                      reply_markup=ReplyKeyboardMarkup(
                                          reply_start,
                                          one_time_keyboard=True,
                                          resize_keyboard=True))

            return START
        elif message == "Tambah sudah, harus ulang":
            santri = get_sudah_tambah_harus_ulang()
            body = "Daftar santri sudah tambah belum lancar (%s)" % count(
                santri)
            body += "\n\n"
            body += "\n".join(s.nama for s in santri)
            body += "\n"

            update.message.reply_text(body,
                                      reply_markup=ReplyKeyboardMarkup(
                                          reply_start,
                                          one_time_keyboard=True,
                                          resize_keyboard=True))

            return START
        else:
            update.message.reply_text(
                "Maaf, kami tidak tahu apa yang kamu mau...!!")
            return START
    else:
        update.message.reply_text("⛔⛔⛔ Maaf, anda tidak terdaftar ⛔⛔⛔")
예제 #6
0
 def test_yang_belum_setor_sama_sekali(self):
     blm_setor = get_belum_setor()
     self.assertEqual(count(blm_setor), 1)
     # self.fail(help(blm_setor))
     self.assertIn('raffi', [santri.nama for santri in blm_setor])
     self.assertNotIn('iqbal', [santri.nama for santri in blm_setor])