django-brain-utils 0.2.5
My app description
License: BSD
Requires Python: >=3.5
Keywords: login,signup,messages,configuration,rehuse

Brain Utils
-----------

Brain Utils is a Django app to let developers do not repeat same initial code for commons utilities. For example
configuration system values in database, configurable messages with traduction, stantard mixins for models and admins, etc.

Quick start
-----------

1. Install:

    ``pip install django-brain-utils``

2. Add "brainutils" to your INSTALLED_APPS setting like this:

    ``INSTALLED_APPS = [
        ...
        'brainutils', # Before allauth
        ...
    ]``

3. To start you can add a configurable message in your home page, example:

    {% load butils %}
    <p>{% display_message request 'home.welcome' %}</p>

4. Run ``python manage.py migrate`` to create the brainutils models.

5. Start the development server, visit http://127.0.0.1:8000 to watch first message and then go http://localhost:8000/admin/brainutils/message/
   to edit the created message, you may set there the message you want all times you need (to refressh changes you need
   to restart your webserver Apache, Nginx, etc). Is easy and you got a total control for each message and it traduction


More utilities
-----------

Configuration variables:

You can set and use in your code a configuration variable very easy like this:

from brainutils import configuration

token = configuration.get_value('api.some.token','HEREYOURINITIALTOKENVALUE')
max_items_per_page = configuration.get_integer('commons.pagination.maxitems','10')

Then you may set a new value whenever you whant in http://localhost:8000/admin/brainutils/configuration/. Again you need
to restart your webserver to refresh changes

Model standart base fields:

`from brainutils import mixins

class MyModel(mixins.AuditMixin):

    field1 = models.TextField(null=True, blank=True)
    field2 = models.TextField(null=True, blank=True)`

Then you have this fields and you may use like you want:
creation_date, modification_date, creation_user, modification_user, status

Extra Models Administrator Skills

If you need to interact with your model administrator with extra tags or actions you can use something like this:

`class MyModelAdmin(mixadmin.ModelAdminMixin):

    list_display = ('field1', 'field2', 'modification_date', 'extra_actions')
    
    def myaction_view(self, request, id):
        try:
            obj = models.MyModel.objects.get(pk = id)
            success = obj.do_action()
            if success:
                return self.response_view(request, True, 'myaction_view', 'OK')
            else:
                return self.response_view(request, False, 'myaction_view', 'FAIL')
        except Exception as e:
            return self.response_view(request, False, 'myaction_view', str(e))

    def get_specific_dual_methods(self, obj):
        return [
            {'name':'actionname', 'activation':True, 'color':self.ENABLED_COLOR, 
            'myaction_view':self.myaction_view},
        ]`

Language Manager

Youre application may needs to be multilanguage, theres an easy way with Brain Utils, just set in your code:

`from brainutils import messages

def my_view(request):

    current_language = messages.languages.get_language(request)
    
    # Do whatever you want with language object
    
    # You may change the current language online in each moment if you need
    
    messages.languages.change_language(request,'english')`

In templates:

{% for l in LANGUAGES %}
    {{l.title}}
{% endfor %}

Then you may set a new language value whenever you whant in http://localhost:8000/admin/brainutils/language/.

Customers Accounts

Brainutils gives you an standard login, signup and more functionalities for customers in your application.

To customize messages and else, copy our templates/account/ folder and change there whatever you want. You may
reuse a lot of funcionality inside there if your application web structure is similar. We use bootstrap as this:

<div class="main-container">
    <div class="inside-container">
        <!-- HERE PAGE CONTENT -->
    </div>
</div>

Code Generation

With Django Brain Utils you can generate repetitive code, as the Model Admins, for that objetive we have a console,
you can run the console from this command:

``./manage.py codegen``

And this menu will be displayed:

Welcome to Brain Utils
_________________________

BRAIN UTILS GENERATOR
What we gonna do?:
1. Generate Admins
2. Generate URLs- Views
3. Generate Signup - Login
0. Exit
***************************
Select and option[and press ENTER]:

By the moment with just try with option 1, is very intuitive and easy to generate admins code.