# -*- coding: utf-8 -*-

from south.db import db
from django.db import models
from libra.books.models import *

class Migration:
    
    def forwards(self, orm):
        
        # Adding model 'BookItem'
        db.create_table('books_bookitem', (
            ('comment', models.CharField(max_length=255, verbose_name=u'примечание')),
            ('location_string', models.CharField(max_length=200, verbose_name=u'где находится')),
            ('office', models.ForeignKey(orm['users.Office'], null=True, verbose_name=u'офис', blank=True)),
            ('registrator_staff', models.ForeignKey(orm['users.Staff'], related_name='registersbook', null=True, verbose_name=u'книгу добавил', blank=True)),
            ('year', models.IntegerField(null=True, verbose_name=u'год издания', blank=True)),
            ('is_active', models.BooleanField(default=True, verbose_name=u'экземпляр доступен')),
            ('reg_date', models.DateTimeField(auto_now_add=True, verbose_name=u'дата регистрации в БД')),
            ('book', models.ForeignKey(orm.Book, verbose_name=u'книга')),
            ('ownership_choices', models.CharField(max_length=2, verbose_name=u'принадлежность')),
            ('owner', models.ForeignKey(orm['users.Staff'], related_name="ownedbookitems", null=True, blank=True)),
            ('is_paper', models.BooleanField(verbose_name=u'электронная копия')),
            ('location_staff', models.ForeignKey(orm['users.Staff'], related_name='holdingbookitems', null=True, verbose_name=u'у кого', blank=True)),
            ('id', models.AutoField(primary_key=True)),
            ('cost', models.DecimalField(null=True, verbose_name=u'стоимость', max_digits=7, decimal_places=2, blank=True)),
        ))
        db.send_create_signal('books', ['BookItem'])
        
        # Adding model 'Book'
        db.create_table('books_book', (
            ('publisher', models.ForeignKey(orm.Publisher, null=True, verbose_name=u'издательство', blank=True)),
            ('id', models.AutoField(primary_key=True)),
            ('authors_string', models.CharField(max_length=255, verbose_name=u'авторы (одной строкой)', blank=True)),
            ('title', models.CharField(max_length=255, verbose_name=u'название')),
        ))
        db.send_create_signal('books', ['Book'])
        
        # Adding model 'Publisher'
        db.create_table('books_publisher', (
            ('id', models.AutoField(primary_key=True)),
            ('name', models.CharField(unique=True, max_length=250, verbose_name=u'название')),
        ))
        db.send_create_signal('books', ['Publisher'])
        
        # Adding model 'ReadHistory'
        db.create_table('books_readhistory', (
            ('get_date', models.DateTimeField(null=True, verbose_name=u'когда взяли почитать', blank=True)),
            ('book', models.ForeignKey(orm.Book)),
            ('book_item', models.ForeignKey(orm.BookItem, null=True, blank=True)),
            ('reader', models.ForeignKey(orm['users.Staff'])),
            ('id', models.AutoField(primary_key=True)),
            ('return_date', models.DateTimeField(null=True, verbose_name=u'дата возврата', blank=True)),
        ))
        db.send_create_signal('books', ['ReadHistory'])
        
        # Adding model 'Opinion'
        db.create_table('books_opinion', (
            ('date', models.DateTimeField(auto_now_add=True, verbose_name=u'Дата отзыва')),
            ('text', models.TextField(verbose_name=u'отзыв', blank=True)),
            ('book', models.ForeignKey(orm.Book)),
            ('id', models.AutoField(primary_key=True)),
            ('reader', models.ForeignKey(orm['users.Staff'], verbose_name=u'читатель')),
        ))
        db.send_create_signal('books', ['Opinion'])
        
    
    
    def backwards(self, orm):
        
        # Deleting model 'BookItem'
        db.delete_table('books_bookitem')
        
        # Deleting model 'Book'
        db.delete_table('books_book')
        
        # Deleting model 'Publisher'
        db.delete_table('books_publisher')
        
        # Deleting model 'ReadHistory'
        db.delete_table('books_readhistory')
        
        # Deleting model 'Opinion'
        db.delete_table('books_opinion')
        
    
    
    models = {
        'users.office': {
            '_stub': True,
            'id': ('models.AutoField', [], {'primary_key': 'True'})
        },
        'books.bookitem': {
            'book': ('models.ForeignKey', ['Book'], {'verbose_name': "u'\xd0\xba\xd0\xbd\xd0\xb8\xd0\xb3\xd0\xb0'"}),
            'comment': ('models.CharField', [], {'max_length': '255', 'verbose_name': "u'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xbc\xd0\xb5\xd1\x87\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb5'"}),
            'cost': ('models.DecimalField', [], {'null': 'True', 'verbose_name': "u'\xd1\x81\xd1\x82\xd0\xbe\xd0\xb8\xd0\xbc\xd0\xbe\xd1\x81\xd1\x82\xd1\x8c'", 'max_digits': '7', 'decimal_places': '2', 'blank': 'True'}),
            'id': ('models.AutoField', [], {'primary_key': 'True'}),
            'is_active': ('models.BooleanField', [], {'default': 'True', 'verbose_name': "u'\xd1\x8d\xd0\xba\xd0\xb7\xd0\xb5\xd0\xbc\xd0\xbf\xd0\xbb\xd1\x8f\xd1\x80 \xd0\xb4\xd0\xbe\xd1\x81\xd1\x82\xd1\x83\xd0\xbf\xd0\xb5\xd0\xbd'"}),
            'is_paper': ('models.BooleanField', [], {'verbose_name': "u'\xd1\x8d\xd0\xbb\xd0\xb5\xd0\xba\xd1\x82\xd1\x80\xd0\xbe\xd0\xbd\xd0\xbd\xd0\xb0\xd1\x8f \xd0\xba\xd0\xbe\xd0\xbf\xd0\xb8\xd1\x8f'"}),
            'location_staff': ('models.ForeignKey', ['Staff'], {'related_name': "'holdingbookitems'", 'null': 'True', 'verbose_name': "u'\xd1\x83 \xd0\xba\xd0\xbe\xd0\xb3\xd0\xbe'", 'blank': 'True'}),
            'location_string': ('models.CharField', [], {'max_length': '200', 'verbose_name': "u'\xd0\xb3\xd0\xb4\xd0\xb5 \xd0\xbd\xd0\xb0\xd1\x85\xd0\xbe\xd0\xb4\xd0\xb8\xd1\x82\xd1\x81\xd1\x8f'"}),
            'office': ('models.ForeignKey', ['Office'], {'null': 'True', 'verbose_name': "u'\xd0\xbe\xd1\x84\xd0\xb8\xd1\x81'", 'blank': 'True'}),
            'owner': ('models.ForeignKey', ['Staff'], {'related_name': '"ownedbookitems"', 'null': 'True', 'blank': 'True'}),
            'ownership_choices': ('models.CharField', [], {'max_length': '2', 'verbose_name': "u'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xbd\xd0\xb0\xd0\xb4\xd0\xbb\xd0\xb5\xd0\xb6\xd0\xbd\xd0\xbe\xd1\x81\xd1\x82\xd1\x8c'"}),
            'reg_date': ('models.DateTimeField', [], {'auto_now_add': 'True', 'verbose_name': "u'\xd0\xb4\xd0\xb0\xd1\x82\xd0\xb0 \xd1\x80\xd0\xb5\xd0\xb3\xd0\xb8\xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8 \xd0\xb2 \xd0\x91\xd0\x94'"}),
            'registrator_staff': ('models.ForeignKey', ['Staff'], {'related_name': "'registersbook'", 'null': 'True', 'verbose_name': "u'\xd0\xba\xd0\xbd\xd0\xb8\xd0\xb3\xd1\x83 \xd0\xb4\xd0\xbe\xd0\xb1\xd0\xb0\xd0\xb2\xd0\xb8\xd0\xbb'", 'blank': 'True'}),
            'year': ('models.IntegerField', [], {'null': 'True', 'verbose_name': "u'\xd0\xb3\xd0\xbe\xd0\xb4 \xd0\xb8\xd0\xb7\xd0\xb4\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x8f'", 'blank': 'True'})
        },
        'books.book': {
            'authors_string': ('models.CharField', [], {'max_length': '255', 'verbose_name': "u'\xd0\xb0\xd0\xb2\xd1\x82\xd0\xbe\xd1\x80\xd1\x8b (\xd0\xbe\xd0\xb4\xd0\xbd\xd0\xbe\xd0\xb9 \xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xbe\xd0\xb9)'", 'blank': 'True'}),
            'id': ('models.AutoField', [], {'primary_key': 'True'}),
            'publisher': ('models.ForeignKey', ['Publisher'], {'null': 'True', 'verbose_name': "u'\xd0\xb8\xd0\xb7\xd0\xb4\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c\xd1\x81\xd1\x82\xd0\xb2\xd0\xbe'", 'blank': 'True'}),
            'title': ('models.CharField', [], {'max_length': '255', 'verbose_name': "u'\xd0\xbd\xd0\xb0\xd0\xb7\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb5'"})
        },
        'books.publisher': {
            'id': ('models.AutoField', [], {'primary_key': 'True'}),
            'name': ('models.CharField', [], {'unique': 'True', 'max_length': '250', 'verbose_name': "u'\xd0\xbd\xd0\xb0\xd0\xb7\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb5'"})
        },
        'books.readhistory': {
            'book': ('models.ForeignKey', ['Book'], {}),
            'book_item': ('models.ForeignKey', ['BookItem'], {'null': 'True', 'blank': 'True'}),
            'get_date': ('models.DateTimeField', [], {'null': 'True', 'verbose_name': "u'\xd0\xba\xd0\xbe\xd0\xb3\xd0\xb4\xd0\xb0 \xd0\xb2\xd0\xb7\xd1\x8f\xd0\xbb\xd0\xb8 \xd0\xbf\xd0\xbe\xd1\x87\xd0\xb8\xd1\x82\xd0\xb0\xd1\x82\xd1\x8c'", 'blank': 'True'}),
            'id': ('models.AutoField', [], {'primary_key': 'True'}),
            'reader': ('models.ForeignKey', ['Staff'], {}),
            'return_date': ('models.DateTimeField', [], {'null': 'True', 'verbose_name': "u'\xd0\xb4\xd0\xb0\xd1\x82\xd0\xb0 \xd0\xb2\xd0\xbe\xd0\xb7\xd0\xb2\xd1\x80\xd0\xb0\xd1\x82\xd0\xb0'", 'blank': 'True'})
        },
        'users.staff': {
            '_stub': True,
            'id': ('models.AutoField', [], {'primary_key': 'True'})
        },
        'books.opinion': {
            'book': ('models.ForeignKey', ['Book'], {}),
            'date': ('models.DateTimeField', [], {'auto_now_add': 'True', 'verbose_name': "u'\xd0\x94\xd0\xb0\xd1\x82\xd0\xb0 \xd0\xbe\xd1\x82\xd0\xb7\xd1\x8b\xd0\xb2\xd0\xb0'"}),
            'id': ('models.AutoField', [], {'primary_key': 'True'}),
            'reader': ('models.ForeignKey', ['Staff'], {'verbose_name': "u'\xd1\x87\xd0\xb8\xd1\x82\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c'"}),
            'text': ('models.TextField', [], {'verbose_name': "u'\xd0\xbe\xd1\x82\xd0\xb7\xd1\x8b\xd0\xb2'", 'blank': 'True'})
        }
    }
    
    complete_apps = ['books']
