
I want to continue a good tradition:
and tell about the successful solutions applied 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 following. Projects have evolved and got better and better.
But what if sharing the experience not within the department, but as
a whole community of Russian jungists?
')
What's inside
Our project is not 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 allotted time, otherwise the project manager will receive angry robo letters.
A small example is 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 still trying out the business model and not everything is fully automated. Therefore, today I will focus on the outer part. Some project requirements:
- the ability to quickly change the texts on the site to several non-technical people;
- maximum convenience for the client;
- multilingual.
Well, as promised, we proceed to a positive experience.
dbtemplates
I think this
application is a jewel among the finds of this project :)
DBTemplates provides the simplest functionality -
storing and editing Django templates in a database .
At the same time, it supports the wonderful HTML editor
CodeMirror and stores the entire history of changes with the help of
django-reversion .
It looks like this:

This simple solution fully satisfied our needs for changing the texts on the site. On another project, we tried DjangoCMS, but this is just hell. Say it is not suitable for users? Maybe, but after a brief excursus, the girls of the PR specialists successfully rule and create the pages of the site.
Not without minor improvements:
- 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 the templates once an hour.
And oddly enough, this system works great for our project. Most likely, we will throw out DjangoCMS from e-Legion.ru in favor of dbtemplates.

While we have not completed one little thing - editing the menu and creating new pages, but I think
django-treemenus will cope with this task. After implementation on e-legion I will tell you in more detail.
autologin-token
I created this application as part of the project, it is small and unfinished :) But very useful.
The idea is simple: allow the user to enter the project automatically from the power supply.
Solution: we create model and middleware and we can add the parameter
autotoken=ER2332FFF
to any link, 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 insert it into the email:
data[ 'autologin_token' ] = AutologinToken . objects . generate(target_user)
The source code of the application (do not scold too much, there was no time to comb)
django-robokassa
The name of the application indicates its purpose. There is almost nothing for me to say here, except
Many thanks to kmike . I could not have imagined that everything would be so simple, in 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 into the account.
There is an idea in the future to create applications for the payment screen, like Elba. Can someone tell the ready?

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 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 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 perfectly! Native speakers completely
independently translate the portal, immediately observe the result and correct the errors.
django-localeurl
And last for today
django-localeurl application . 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 unequivocally points to an English site.
In previous projects, the languages we defined were automaton and stored in cookies; this is a bad decision for two reasons:
- search engines will not be able to reach content in another language;
- when you give a link to some article, it is likely that a user with incorrect language settings will receive 404.
Therefore, we decided that the
URL uniquely identifies the language . Localeurl is great at helping out; he is responsible for both changing the language from the link and modifying the links on the page (overrides {% url%}).
That's all
Instead of concluding, I’ll give an answer to my question if sharing experiences 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 :)