from apps.backups import site from .models import Trigger site.register(Trigger)
from apps.backups import site from .models import Group, Membership, User, UserSocialProfile site.register([Group, User, Membership, UserSocialProfile])
from apps.backups import site from apps.backups.options import ModelBackupByName from .models import Channel site.register(Channel, ModelBackupByName)
def backup_object(self, storage, obj): # Remove CNAME and set ssl status to off on backup obj['ssl_status'] = Hosting.SSL_STATUSES.OFF cname = Hosting.find_cname(obj['domains']) if cname: obj['domains'].remove(cname) super().backup_object(storage, obj) class HostingFileBackup(ModelBackup): include_details = 'count' def backup_object(self, storage, obj): path = obj['file_object'] obj['file_object'] = storage.add_file(Hosting.get_storage().open(path)) super().backup_object(storage, obj) def to_instance(self, storage, representation): file_object = storage.get_file(representation['file_object']) storage.update_storage_size(file_object.size) new_path = upload_hosting_file_to(Munch(representation), os.path.basename(file_object.name)) Hosting.get_storage().save(new_path, file_object) representation['file_object'] = new_path return super().to_instance(storage, representation) site.register(Hosting, HostingBackup) site.register(HostingFile, HostingFileBackup)
from apps.backups import site from apps.backups.options import ModelBackupByName from .models import ResponseTemplate site.register(ResponseTemplate, ModelBackupByName)
from apps.backups import site from apps.backups.options import ModelBackupByName from .models import Webhook site.register(Webhook, ModelBackupByName)
class DataObjectBackup(ModelBackup): include_details = 'count' def backup_object(self, storage, obj): for key in obj['_files']: path = obj['_data'][key] obj['_data'][key] = storage.add_file(default_storage.open(path)) super().backup_object(storage, obj) def restore(self, storage, restore_context=None): # Get rid of any schema associated with DataObject, because it could # introduce other Klass-es fields to _data dictionary DataObject._meta.get_field('_data').reload_schema(None) return super().restore(storage, restore_context) def to_instance(self, storage, representation): for file_field in representation['_files']: file = storage.get_file(representation['_data'][file_field]) storage.update_storage_size(file.size) new_path = upload_file_to(Munch(representation), os.path.basename(file.name)) default_storage.save(new_path, file) representation['_data'][file_field] = new_path return super().to_instance(storage, representation) site.register(Klass, KlassBackup) site.register(DataObject, DataObjectBackup)
# coding=UTF8 from apps.backups import site from apps.backups.options import ModelBackupByName from .models import DataObjectHighLevelApi site.register(DataObjectHighLevelApi, ModelBackupByName)
default_storage.save(new_path, f) file_data['file'] = new_path return super().to_instance(storage, representation) class SocketEnvironmentBackup(ModelBackupByName): def backup_object(self, storage, obj): for f in ('zip_file', 'fs_file'): if obj[f]: obj[f] = storage.add_file(default_storage.open(obj[f])) super().backup_object(storage, obj) def to_instance(self, storage, representation): for f in ('zip_file', 'fs_file'): if f in representation and representation[f]: file_object = storage.get_file(representation[f]) new_path = upload_custom_socketenvironment_file_to( Munch(representation), os.path.basename(file_object.name)) default_storage.save(new_path, file_object) representation[f] = new_path return super().to_instance(storage, representation) site.register(Socket, SocketBackup) site.register(SocketEndpoint, ModelBackupByName) site.register(SocketHandler) site.register(SocketEnvironment, SocketEnvironmentBackup)
from apps.backups import site from .models import APNSConfig, APNSDevice, GCMConfig, GCMDevice site.register([GCMDevice, GCMConfig, APNSDevice, APNSConfig])
from apps.backups import site from .models import CodeBox, CodeBoxSchedule site.register([CodeBox, CodeBoxSchedule])