added establishment and collection transfer.py files

This commit is contained in:
michail 2019-10-03 17:54:26 +05:00
parent cf7184d7ac
commit 018d9f6557
3 changed files with 428 additions and 0 deletions

View File

@ -0,0 +1,42 @@
"""
Структура fields:
key - поле в таблице postgres
value - поле или группа полей в таблице legacy
В случае передачи группы полей каждое поле представляет собой кортеж, где:
field[0] - название аргумента
field[1] - название поля в таблице legacy
Опционально: field[2] - тип данных для преобразования
"""
card = {
"Collection": {
"dependencies": ("Country", ),
"fields": {
"Collections": {
# нету аналогов для полей start и end
"name": "title",
"slug": "slug",
}
},
"relations": {
"country": "Country",
}
},
"Guide": {
"dependencies": ("Collection", ),
"fields": {
"Guides": {
# нету аналогов для полей start и end
"name": "title"
}
},
"relations": {
"parent": "Guide",
"collection": "Collection"
}
}
}
used_apps = ("location", )

View File

@ -0,0 +1,70 @@
"""
Структура fields:
key - поле в таблице postgres
value - поле или группа полей в таблице legacy
В случае передачи группы полей каждое поле представляет собой кортеж, где:
field[0] - название аргумента
field[1] - название поля в таблице legacy
Опционально: field[2] - тип данных для преобразования
"""
card = {
"Establishment": {
"dependencies": ("Address", "Collection", ),
# нету аналогов для establishment_type, establishment_subtypes, schedule, comments, tags
"fields": {
"Establishments": {
"name": "name",
"slug": "slug"
},
"EstablishmentInfos": {
"website": "website",
"facebook": "facebook",
"twitter": "twitter",
"lafourchette": "lafourchette",
"booking": "booking_url"
},
},
"relations": {
"address": "Address",
# "establishment_type": "EstablishmentType",
# "establishment_subtypes": "EstablishmentSubType",
"collections": "Collection",
# "schedule": "Timetable",
"award": "Award",
# "tags": "MetaDataContent",
"reviews": "Review",
# "comments": "Comment",
# "favorites": "Favorites"
}
},
"Menu": {
"dependencies": ("Establishment", ),
"fields": {
"Menus": {
"category": ("name", "TJSONField")
}
},
"relations": {
"establishment": "Establishment"
}
},
"ContactPhone": {
"dependencies": ("Establishment", ),
"fields": {
"Establishments": {
"phone": "phone"
},
"relations": {
"establishment": "Establishment"
}
}
}
}
used_apps = ("review", "location", "collection", "main", "timetable", "favorites", "comment", )

View File

@ -91,3 +91,319 @@ class Locations(models.Model):
class Meta:
managed = False
db_table = 'locations'
class Collections(MigrateMixin):
using = 'legacy'
title = models.CharField(max_length=255, blank=True, null=True)
tag_name = models.CharField(max_length=255, blank=True, null=True)
slug = models.CharField(max_length=255, blank=True, null=True)
site_id = models.IntegerField(blank=True, null=True)
active = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
attachment_file_name = models.CharField(max_length=255, blank=True, null=True)
attachment_content_type = models.CharField(max_length=255, blank=True, null=True)
attachment_file_size = models.IntegerField(blank=True, null=True)
attachment_updated_at = models.DateTimeField(blank=True, null=True)
geometries = models.CharField(max_length=1024, blank=True, null=True)
aasm_state = models.CharField(max_length=255, blank=True, null=True)
class Meta:
managed = False
db_table = 'collections'
# class CollectionEvents(MigrateMixin):
# using = 'legacy'
#
# account = models.ForeignKey(Accounts, models.DO_NOTHING, blank=True, null=True)
# account_collection = models.ForeignKey(AccountCollections, models.DO_NOTHING, blank=True, null=True)
# possible_dates = models.CharField(max_length=255, blank=True, null=True)
# final_date = models.DateTimeField(blank=True, null=True)
# establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
# created_at = models.DateTimeField()
# updated_at = models.DateTimeField()
#
# class Meta:
# managed = False
# db_table = 'collection_events'
# class CollectionEventAvailabilities(MigrateMixin):
# using = 'legacy'
#TODO: collection_event - внешний ключ к CollectionEvents, которая имеет внешний ключ к Accounts
# collection_event = models.ForeignKey('CollectionEvents', models.DO_NOTHING, blank=True, null=True)
# establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
# email_address = models.ForeignKey('EmailAddresses', models.DO_NOTHING, blank=True, null=True)
# date = models.DateTimeField(blank=True, null=True)
# state = models.CharField(max_length=255, blank=True, null=True)
# created_at = models.DateTimeField()
# updated_at = models.DateTimeField()
#
# class Meta:
# managed = False
# db_table = 'collection_event_availabilities'
class Guides(MigrateMixin):
using = 'legacy'
title = models.CharField(max_length=255, blank=True, null=True)
vintage = models.IntegerField(blank=True, null=True)
slug = models.CharField(max_length=255, blank=True, null=True)
state = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
site_id = models.IntegerField(blank=True, null=True)
inserter_field = models.CharField(max_length=255, blank=True, null=True)
items_count = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'guides'
class GuideAds(MigrateMixin):
using = 'legacy'
nb_pages = models.IntegerField(blank=True, null=True)
nb_right_pages = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
guide_ad_node_id = models.IntegerField(blank=True, null=True)
type = models.CharField(max_length=255, blank=True, null=True)
class Meta:
managed = False
db_table = 'guide_ads'
class GuideFilters(MigrateMixin):
using = 'legacy'
year = models.TextField(blank=True, null=True)
establishment_type = models.CharField(max_length=255, blank=True, null=True)
countries = models.TextField(blank=True, null=True)
regions = models.TextField(blank=True, null=True)
subregions = models.TextField(blank=True, null=True)
wine_regions = models.TextField(blank=True, null=True)
wine_classifications = models.TextField(blank=True, null=True)
wine_colors = models.TextField(blank=True, null=True)
wine_types = models.TextField(blank=True, null=True)
max_mark = models.FloatField(blank=True, null=True)
min_mark = models.FloatField(blank=True, null=True)
marks_only = models.IntegerField(blank=True, null=True)
locales = models.CharField(max_length=255, blank=True, null=True)
states = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
guide_id = models.IntegerField(blank=True, null=True)
class Meta:
managed = False
db_table = 'guide_filters'
class GuideSections(MigrateMixin):
using = 'legacy'
type = models.CharField(max_length=255)
key_name = models.CharField(max_length=255, blank=True, null=True)
value_name = models.CharField(max_length=255, blank=True, null=True)
right = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
# class GuideElements(MigrateMixin):
# using = 'legacy'
#
# type = models.CharField(max_length=255)
# establishment = models.ForeignKey(Establishments, models.DO_NOTHING, blank=True, null=True)
# review = models.ForeignKey('Reviews', models.DO_NOTHING, blank=True, null=True)
# review_text = models.ForeignKey('ReviewTexts', models.DO_NOTHING, blank=True, null=True)
# wine_region = models.ForeignKey('WineLocations', models.DO_NOTHING, blank=True, null=True)
# wine = models.ForeignKey('Products', models.DO_NOTHING, blank=True, null=True)
# color = models.CharField(max_length=255, blank=True, null=True)
# order_number = models.IntegerField(blank=True, null=True)
# guide_ad = models.ForeignKey(GuideAds, models.DO_NOTHING, blank=True, null=True)
# city = models.ForeignKey(Cities, models.DO_NOTHING, blank=True, null=True)
# section = models.ForeignKey('GuideSections', models.DO_NOTHING, blank=True, null=True)
# guide_id = models.IntegerField(blank=True, null=True)
# parent_id = models.IntegerField(blank=True, null=True)
# lft = models.IntegerField()
# rgt = models.IntegerField()
# depth = models.IntegerField()
# children_count = models.IntegerField()
# created_at = models.DateTimeField()
# updated_at = models.DateTimeField()
#
# class Meta:
# managed = False
# db_table = 'guide_elements'
class Establishments(MigrateMixin):
using = 'legacy'
name = models.CharField(max_length=255)
index_name = models.CharField(max_length=255, blank=True, null=True)
slug = models.CharField(unique=True, max_length=255, blank=True, null=True)
phone = models.CharField(max_length=255, blank=True, null=True)
fax = models.CharField(max_length=255, blank=True, null=True)
type = models.CharField(max_length=255, blank=True, null=True)
location = models.ForeignKey('Locations', models.DO_NOTHING, blank=True, null=True)
unique_key = models.CharField(max_length=255, blank=True, null=True)
filemaker_id = models.IntegerField(unique=True, blank=True, null=True)
aut_mysql_id = models.IntegerField(unique=True, blank=True, null=True)
fra_encima_id = models.IntegerField(blank=True, null=True)
ca_import_id = models.IntegerField(blank=True, null=True)
ch_import_id = models.IntegerField(blank=True, null=True)
be_ezpublish_id = models.IntegerField(blank=True, null=True)
au_import_id = models.IntegerField(blank=True, null=True)
lux_import_id = models.IntegerField(blank=True, null=True)
hun_import_id = models.IntegerField(blank=True, null=True)
deu_import_id = models.IntegerField(blank=True, null=True)
win_import_id = models.TextField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
state = models.CharField(max_length=255, blank=True, null=True)
manager_revised_at = models.DateTimeField(blank=True, null=True)
cover_id = models.IntegerField(blank=True, null=True)
parent_id = models.IntegerField(blank=True, null=True)
admin_updated_at = models.DateTimeField(blank=True, null=True)
admin_updated_by = models.IntegerField(blank=True, null=True)
company_id = models.IntegerField(blank=True, null=True)
production_type = models.CharField(max_length=3000, blank=True, null=True)
class Meta:
managed = False
db_table = 'establishments'
# class EstablishmentAssets(MigrateMixin):
# using = 'legacy'
#
# establishment = models.ForeignKey('Establishments', models.DO_NOTHING)
# account = models.ForeignKey(Accounts, models.DO_NOTHING, blank=True, null=True)
# menu_id = models.IntegerField(blank=True, null=True)
# type = models.CharField(max_length=64)
# scope = models.CharField(max_length=32)
# created_at = models.DateTimeField()
# updated_at = models.DateTimeField()
# attachment_file_name = models.CharField(max_length=255, blank=True, null=True)
# attachment_content_type = models.CharField(max_length=255, blank=True, null=True)
# geometries = models.CharField(max_length=1024, blank=True, null=True)
# attachment_file_size = models.IntegerField(blank=True, null=True)
# attachment_updated_at = models.DateTimeField(blank=True, null=True)
#
# class Meta:
# managed = False
# db_table = 'establishment_assets'
class EstablishmentBacklinks(MigrateMixin):
using = 'legacy'
establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
partnership_name = models.CharField(max_length=255, blank=True, null=True)
partnership_icon = models.CharField(max_length=255, blank=True, null=True)
backlink_url = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
type = models.CharField(max_length=255, blank=True, null=True)
starting_date = models.DateField(blank=True, null=True)
expiry_date = models.DateField(blank=True, null=True)
price_per_month = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
class Meta:
managed = False
db_table = 'establishment_backlinks'
# class EstablishmentCollections(MigrateMixin):
# using = 'legacy'
#
# establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
# account_collection = models.ForeignKey(AccountCollections, models.DO_NOTHING, blank=True, null=True)
# created_at = models.DateTimeField()
# updated_at = models.DateTimeField()
#
# class Meta:
# managed = False
# db_table = 'establishment_collections'
class EstablishmentHolidays(MigrateMixin):
using = 'legacy'
start_date = models.DateField(blank=True, null=True)
end_date = models.DateField(blank=True, null=True)
establishment_id = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'establishment_holidays'
class EstablishmentInfos(MigrateMixin):
using = 'legacy'
establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
email = models.CharField(max_length=255, blank=True, null=True)
website = models.CharField(max_length=255, blank=True, null=True)
facebook = models.CharField(max_length=255, blank=True, null=True)
twitter = models.CharField(max_length=255, blank=True, null=True)
lafourchette = models.CharField(max_length=255, blank=True, null=True)
pub = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
booking_url = models.CharField(max_length=255, blank=True, null=True)
nb_slot = models.IntegerField(blank=True, null=True)
booking_enabled = models.IntegerField(blank=True, null=True)
guestonline_id = models.IntegerField(blank=True, null=True)
guestonline_auth_token = models.CharField(max_length=255, blank=True, null=True)
class Meta:
managed = False
db_table = 'establishment_infos'
# class EstablishmentMerchandises(MigrateMixin):
# using = 'legacy'
#
# establishment = models.ForeignKey('Establishments', models.DO_NOTHING, blank=True, null=True)
#TODO: модели Merchandises нету в гугл таблице Check Migrations
# merchandise = models.ForeignKey('Merchandises', models.DO_NOTHING, blank=True, null=True)
# gifted = models.IntegerField(blank=True, null=True)
# quantity = models.IntegerField(blank=True, null=True)
# created_at = models.DateTimeField()
# updated_at = models.DateTimeField()
#
# class Meta:
# managed = False
# db_table = 'establishment_merchandises'
class Menus(MigrateMixin):
using = 'legacy'
establishment = models.ForeignKey(Establishments, models.DO_NOTHING, blank=True, null=True)
name = models.CharField(max_length=255, blank=True, null=True)
timing = models.CharField(max_length=255, blank=True, null=True)
price = models.FloatField(blank=True, null=True)
currency = models.CharField(max_length=255, blank=True, null=True)
drinks = models.CharField(max_length=255, blank=True, null=True)
served_on_offdays = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
class Meta:
managed = False
db_table = 'menus'