Back to Home

Django project PR Hero: what's inside and experience gained

django · dbtemplates · localeurl · rosetta · autologin token · pr-hero · freshp · robokassa

Django project PR Hero: what's inside and experience gained


    I want to continue a good tradition:
    and tell about the successful solutions used in the Django project PR-Hero .

    I urge everyone to do the same and share their experiences :) I will explain why. In our team, every successful solution or application from one project was necessarily used in the next. Projects have evolved and become better and better.

    But what if you share your experience not within the department, but with a whole community of Russian dzhangists?

    What's inside


    Our project is not called technically difficult. In fact, this is an online store of one service and, apparently, the most difficult part is payment through Robokassa.

    Inside, everything is a little more interesting: as in any good online store, we automate business processes. For example, we make sure that each stage takes no more than the time set for it, otherwise the project manager will receive angry robo-letters.

    A small example - possible examples of application states:
    STATUSES_WORKFLOW = {
        'new': ['owned', 'cancelled'],
        'owned': ['bullshit', 'cancelled', 'wait_payment'],
        'bullshit': [],
        'wait_payment': ['unpayed', 'cancelled', 'write_release'],
        'unpayed': [],
        'write_release': ['wait_approval', 'cancelled',],
        'wait_approval': ['sending_release', 'cancelled'],
        'sending_release': ['feedback', 'cancelled'],
        'feedback': ['finished', 'cancelled'],
        'finished': [],
        'cancelled': [],
    }


    Unfortunately, we are just trying the business model and not everything is fully automated. Therefore, today I will focus on the outside. A few requirements for the project:
    • the ability to quickly change the texts on the site to several non-technical people;
    • maximum convenience for the client;
    • multilingualism.
    Well, and as promised, we proceed to a positive experience.

    dbtemplates


    I consider this application a gem among the finds of this project :)

    DBTemplates provides the simplest functionality -  storing and editing Django templates in the database .

    At the same time, it supports the wonderful HTML editor CodeMirror and stores the entire history of changes using django-reversion .

    It looks something like this:



    This simple solution completely satisfied our needs for changing the texts on the site. On another project, we tried DjangoCMS, but it's just hell. Say that this is not suitable for users? Maybe, but the girls PR-schiki after a brief excursion successfully rule and create the site pages.

    Not without minor modifications:
    • The sync_templates command has been fixed to work with unicode and to automatically create files when synchronizing with the database;
    • and a simple script was written that automatically commits templates once an hour.
    And oddly enough, this system works great for our project. Most likely, we will throw DjangoCMS from e-Legion.ru in favor of dbtemplates.
    counter customizable

    So far we have not completed one little thing - editing the menu and creating new pages, but I think django-treemenus will completely cope with this task. After implementation on e-legion I will tell in more detail.

    autologin-token


    I created this application as part of the project, it is small and unfinished :) But it is very useful.

    The idea is simple: allow the user to log into the project automatically from email.

    Solution: we create a modelka and middleware and we can add a parameter to any link autotoken=ER2332FFF, and the user is authenticated on the site automatically.
    http://pr-hero.ru/manage_request/15/?autologin_token=ER2332FFF
    Using the application is simple - generate a token for the user and paste in the letter:
    data['autologin_token'] = AutologinToken.objects.generate(target_user)
    The source code of the application (do not scold much, there was no time to comb)

    django-robokassa


    The name of the application indicates its purpose. I have almost nothing to say here, except Thank you very much kmike . I could not think that it would be so simple, for half an hour I connected the service to Robokassa .

    Payments with Yandex Money, WebMoney, Terminals and bank cards without problems for us and customers fall to the current account.

    There is an idea in the future to create applications for the payment screen, like Elba's. Can someone tell me the finished?



    django-rosetta


    This application provides invaluable assistance in translating projects into foreign languages. We have already successfully tested in two projects: Goozy and PR-Hero.

    We often have to delegate the translation, for example, Goozy was translated into Ukrainian, Croatian and even Finnish. I had to send po files by mail, give a link to poedit, then merge for a long time and send the untranslated parts back, along the way giving comments on what this or that phrase means.

    Rosetta provides a convenient web-based interface for editing translation files . After we added a simple script that compiles po files and restarts the web server.



    This solution works perfect! Native speakers translate completely independently portal, immediately observe the result and correct errors.

    django-localeurl


    And the latest django-localeurl app for today . It solves a simple problem - the language of the site is determined solely from the link. For example, pr-hero.ru/en/medias or en.pr-hero.ru/medias unambiguously points to an English site.

    In previous projects, our languages ​​were determined automatically and stored in cookies, this is a bad decision for two reasons:
    - search engines will not be able to access content in another language;
    - when you give a link to an article, it is likely that a user with incorrect language settings will receive 404.

    Therefore, we decided that the URL uniquely defines the language . localeurl helps with this, it is responsible both for changing the language of the link and for modifying the links on the page (overrides {% url%}).

    That's all


    Instead of concluding, I will give an answer to my question, if you share experience after completed projects within the community, then all our Django projects and applications will become much better.

    I really hope to see your projects from the inside soon :)

    Read Next