Giter VIP home page Giter VIP logo

spicy.core's Introduction

Code Climate Test Coverage

========== Spicy docs

Fixed version 1.2.0

Main and the one using case:

.. code-block:: sh spicy -h

TODO: write readme in plain text at least

Features at a glance

  • Support for Django >= 1.3 <= 1.5.12
  • Python 2.7 support

How to Use

Get the code

Getting the code for the latest stable release use 'pip'. ::

git+https://gitlab.com/spicycms.com/[email protected]#egg=spicy

Install in your project

your project's settings. ::

LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/signin/'
REGISTRATION_OPEN = True

LOGIN_URL = '/signin/'
LOGIN_REDIRECT_URL = '/'

AUTHENTICATION_BACKENDS = (
    'spicy.core.profile.auth_backends.CustomUserModelBackend',
)

SERVICES = (
    'spicy.core.profile.services.ProfileService',
    'spicy.core.trash.services.TrashService',
) 

INSTALLED_APPS = (
     # Django native apps
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.humanize',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.staticfiles',

    # Spicy core components
    'spicy.core.trash',
    'spicy.core.admin',
    'spicy.core.service',
    'spicy.core.siteskin',
    'spicy.core.simplepages',
)

STATICFILES_FINDERS = (
    'spicy.core.siteskin.loaders.ThemeStaticFinder',
    'spicy.core.siteskin.loaders.AppDirectoriesFinder',
)

TEMPLATE_LOADERS = (
    'spicy.core.siteskin.loaders.ThemeTemplateLoader',
    'django.template.loaders.app_directories.Loader',
    'spicy.core.siteskin.loaders.BackendTemplateLoader',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',

    'spicy.core.profile.context_processors.auth',
    'spicy.core.siteskin.context_processors.base',
    'spicy.core.admin.context_processors.base',

    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.request',
)

MIDDLEWARE_CLASSES = (
    'spicy.core.siteskin.middleware.AjaxMiddleware',
    'spicy.core.siteskin.threadlocals.ThreadLocals',
)

if DEBUG:
MIDDLEWARE_CLASSES += (
    # for developers
    'spicy.core.rmanager.middleware.ProfileMiddleware',
)

Docs

####Custom User Profile В этом разделе описана последовательность действий с примером кода, которая позволит создать кастомную модель профайла. Например, вы хотите добавить поля skype и sms_notification к модели пользователя. Для этого необходимо:

  1. запустить проект со схемой данных для базового профайла
  • в бд вы получаете таблицу test_profile, без дополнительных полей
  • в коде класс-модель profile.TestProfile, без дополнительных полей
  1. создать новую ветку в проекте (apps.webapp), перейти на нее и расширить модель профайла нужными полями
class CustomProfile(AbstractProfile):
    sms_notification = models.BooleanField(_('Use SMS notification'), blank=True, default=False)
    skype = models.CharField(_('Skype'), max_length=255, blank=True, null=True)

    class Meta:
        abstract = False
        db_table = 'test_profile'
  1. добавить в settings.py настройку новой модели профайла
CUSTOM_USER_MODEL = 'webapp.CustomProfile'
  • в бд остается таблица test_profile, без дополнительных полей
  • в коде начинает использоваться класс-модель CustomProfile, с расширенным набором полей
  1. сделать патч таблицы профайла tet_profile - добавить новые поля модели (внутри контейнера db)
begin;
alter table test_profile add column sms_notification boolean default False;
alter table test_profile add column skype varchar(255);
commit;
  • в бд таблица test_profile расширена полями
  • в коде используется расширенный класс пользователя webapp.CustomProfile
  1. сделать патч системных таблиц Django - заменить на уровне бд customprofile на test_profile, чтобы сохранить старые данные пользователей (внутри контейнера db)
begin;
SELECT django_content_type.id into test_id FROM django_content_type WHERE app_label = 'profile' AND model = 'testprofile';
SELECT django_content_type.id into custom_id FROM django_content_type WHERE app_label = 'webapp' AND model = 'customprofile';

update auth_permission set content_type_id = (select * from test_id) where content_type_id = (select * from custom_id);
delete from django_content_type where id = (select * from custom_id);
update django_content_type set app_label = 'webapp', model = 'customprofile' where id=(select * from test_id);

drop table test_id;
drop table custom_id;
commit;

begin;
alter table test_profile_sites rename testprofile_id to customprofile_id;
commit;
  • в бд таблица test_profile расширена полями
  • системные таблицы Django не содержат ссылок на customprofile
  • в коде используется расширенный класс пользователя webapp.CustomProfile
  1. убедиться, что новый профайл работает корректно
  • создание пользователя работает
  • изменение пользователя работает
  • удаление пользователя работает

TODO: write docs TODO: custom User Profile, forms create and edit templates TODO: use API service TODO: base templates for admin panel and formfield TODO: templates tag and filter

Tools

TODO: add used tools

And you must remember

People, who creates your software, in most cases are same to you are. So, you must know: in theory they could be murderers or maniacs, or, even a women. So, it's much better for you to write good code. You have been warned.

spicy.core's People

Contributors

agedz avatar alexprofi avatar antisvin avatar burus avatar dariaplotnikova avatar dedpikhto avatar eugenekonovalov avatar inzem77 avatar jesseyv avatar kulapard avatar maremaremare avatar meamka avatar megabogus avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spicy.core's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.