Setting up the Viju module
- The VIJU module in Smarty is a separate license option, so before you start setting up, make sure your license includes this module.
- Connect the module vii in the Smarty configuration in the INSTALLED_APPS section, restart Smarty and perform data migration.
python /usr/share/nginx/html/microimpuls/smarty/manage.py migrate --settings=settings;
3. Create a hidden tariff package that will be used to allow subscribers to access the VIJU movie catalog (can be called « Access to the VIJU» directory); This tariff package will be automatically included for all imported films so that the film is visible to the subscriber in the catalog.
4. Create a tariff package that will be used to subscribe to the movie package (can be called «Cinema VIJU»). When you buy VIJU movies, this package will be connected to the subscriber in Smarty, and when you disable the package — you will unsubscribe on the VIJU side. This tariff should be made visible, assign a price and frequency.
To subscribe to VIJU, you can also create several rates, which, in addition to VIJU films, will include channels and other services — such rates will be considered bundles.
5. Next, you should configure integration in the administration panel in the section « General settings Client» -> «Integration with the external systems API»:

- Access key, password and encryption key — issued by VIJU
6. After that, you should start the first import of films with the help of the command:
python manage.py viju_sync_content --settings=settings.
Additional parameters:
--remove_outdated — when specified, the import script after the end of work deletes all films with the VIJU handler that were not found in the VIJU catalog, that is, cleans old films.
-client_id — the identifier of the client for which the synchronization is required. It is permissible to specify several customers. By default, synchronization is performed for all clients in Smarty.
The first synchronization can take about an hour due to the download of covers, subsequent synchronizations are faster. For regular synchronization of movies, you need to add a command call to crontab.
7. After the first synchronization, VIJU film genres and their basic mapping on Smarty genres will be created. If suddenly it is noticed that the filtering of VIJU films by genres is incorrect, we recommend going to the section http://smarty.example.com/admin/viju/vijugenremap/ and reconfigure mapping in the right way (and you can add your genres and set up new connections for mapping). With the subsequent synchronization of films, genres will be rebounded.
8. After that, you can check the display of the cinema in the interface — for this you need to connect the subscriber tariff « Access to the VIJU» catalog; — after that, the subscriber will be able to see films in the interface, but on the page of their description there will be a button «Buy»


9. If the internal billing Smarty is used for write-offs and tariff management, then just click the button «Buy» in the interface; and with a sufficient balance, a subscription to the film will occur and it can be viewed. If not, then for testing you can connect this tariff to the subscriber through the admin and check that it is played.
Attention! When connecting the Viju tariff, you need a filled phone number or e-mail from the subscriber.
10. To the button «Buy» there was a purchase of a film not only in Smarty, but also in external billing, you can develop an integration script for our website example.
11. For the correct renewal of subscriptions on the Viju side when using billing you need to add to the crontab management team check_video_subscriptions:
smarty_manage check_video_subscriptions -settings=settings.
The team goes through all subscriptions to the cinema on the Smarty side (internal tariffsubscription objects in the django-admin Smarty) and renews them on the Viju side if necessary. Subscription on the Viju side is created with a margin of 1 day, relative to the subscription within Smarty, so that this management team is guaranteed to have time to work out and renew the movie theater subscription before it ends. It is recommended to run the command at least 1 time per day, and in the case of using the command check_accounts — start the command check_video_subscriptions right after her.