Ejemplo n.º 1
0
 def _skloninefio(self):
     if self.fio_head:
         fio = self.fio_head.split(' ')
         if len(fio) == 3:
             p = Petrovich()
             surname = fio[0]
             name = fio[1]
             lastname = fio[2]
             self.fio_head_rod_pad = p.lastname(
                 surname, Case.GENITIVE) + ' ' + p.firstname(
                     name, Case.GENITIVE) + ' ' + p.middlename(
                         lastname, Case.GENITIVE)
             self.fio_head_dat_pad = p.lastname(
                 surname, Case.DATIVE) + ' ' + p.firstname(
                     name, Case.DATIVE) + ' ' + p.middlename(
                         lastname, Case.DATIVE)
Ejemplo n.º 2
0
def create_paper(aid_request: AidRequest):
    try:
        today = datetime.date.today()
        date = "{} {} {} г.".format(today.day, MONTH_RU[today.month],
                                    today.year)
        user = aid_request.applicant
        userprofile = user.userprofile
        student_info = userprofile.student_info
        sex = get_sex(user)
        if sex == 'female':
            student = "студентки"
            gender = Gender.FEMALE
        else:
            student = "студента"
            gender = Gender.MALE
        p = Petrovich()
        fst = p.firstname(student_info.first_name, Case.GENITIVE, gender)
        lst = p.firstname(student_info.last_name, Case.GENITIVE, gender)
        if userprofile.middlename:
            mdl = p.firstname(userprofile.middlename, Case.GENITIVE, gender)
        else:
            mdl = ""
        name = "{} {} {}".format(lst, fst, mdl)
        context = {
            "student": student,
            "group": str(student_info.group),
            "date": date,
            "name": name,
            "reason": aid_request.category.reason,
        }

        tpl = DocxTemplate(STATIC_ROOT +
                           "/fin_aid/Obrazets_Zayavlenia_Na_Matpomosch.docx")
        tpl.render(context)
        path = MEDIA_ROOT + "/aid_docs/user_{}/".format(user_hash(user))
        filename = "application-{}-{}-{}.docx".format(today.year, today.month,
                                                      today.day)
        os.makedirs(path, exist_ok=True)
        tpl.save(path + filename)
        application = AidDocument(request=aid_request,
                                  is_application_paper=True)
        application.file.save(filename,
                              File(open(path + filename, "rb")),
                              save=True)
        return filename
    except Exception as e:
        logger.exception(e)
Ejemplo n.º 3
0
 def get_name(self, obj):
     if obj.user.profile.curator is None:
         return None
     change_ending = Petrovich()
     return (change_ending.firstname(
         value=obj.user.profile.curator.first_name,
         case=Case.DATIVE,
         # gender=user.profile.curator.gender,
     ) + " " + obj.user.profile.curator.last_name[0] + ".")
Ejemplo n.º 4
0
# coding: utf-8
from petrovich.enums import Case
from petrovich.main import Petrovich

__author__ = 'damirazo <*****@*****.**>'


if __name__ == '__main__':
    strings = [
        (u'Алексеев', u'Алексей', u'Давыдович'),
        (u'Матвеев', u'Денис', u'Евгеньевич'),
        (u'Алимова', u'Алия', u'Маратовна'),
    ]

    petro = Petrovich()

    for (fname, iname, oname) in strings:
        for case in Case.CASES:
            print(u'{} {} {}'.format(
                petro.lastname(fname, case),
                petro.firstname(iname, case),
                petro.middlename(oname, case),
            ))
Ejemplo n.º 5
0
def dative_name(id):
    FI = DB.get_person(id)[1].split(' ')
    petr = Petrovich()
    name = petr.firstname(FI[1], Case.DATIVE)
    return FI[0] + ' ' + name