-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8552588
commit 07e9c23
Showing
16 changed files
with
269 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25608,4 +25608,3 @@ msgstr "Progresso" | |
|
||
#~ msgid "individual" | ||
#~ msgstr "Creation" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
default_app_config = 'horilla_backup.apps.backupConfig' | ||
default_app_config = "horilla_backup.apps.backupConfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
from django.contrib import admin | ||
|
||
from .models import * | ||
|
||
# Register your models here. | ||
|
||
admin.site.register(LocalBackup) | ||
admin.site.register(GoogleDriveBackup) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
from django.apps import AppConfig | ||
from django.apps import AppConfig | ||
|
||
|
||
class BackupConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'horilla_backup' | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "horilla_backup" | ||
|
||
def ready(self): | ||
from django.urls import include, path | ||
|
||
from horilla.urls import urlpatterns | ||
|
||
urlpatterns.append( | ||
path("backup/", include("horilla_backup.urls")), | ||
) | ||
super().ready() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
from googleapiclient.discovery import build | ||
import os | ||
|
||
from google.oauth2 import service_account | ||
from googleapiclient.discovery import build | ||
from googleapiclient.http import MediaFileUpload | ||
import os | ||
|
||
|
||
SCOPES = ['https://www.googleapis.com/auth/drive'] | ||
|
||
|
||
SCOPES = ["https://www.googleapis.com/auth/drive"] | ||
|
||
|
||
def authenticate(service_account_file): | ||
creds = service_account.Credentials.from_service_account_file(service_account_file, scopes=SCOPES) | ||
creds = service_account.Credentials.from_service_account_file( | ||
service_account_file, scopes=SCOPES | ||
) | ||
return creds | ||
|
||
def upload_file(file_path, service_account_file, parent_folder_id): | ||
|
||
def upload_file(file_path, service_account_file, parent_folder_id): | ||
creds = authenticate(service_account_file) | ||
service = build('drive', 'v3', credentials=creds) | ||
service = build("drive", "v3", credentials=creds) | ||
parent_folder_id = parent_folder_id | ||
|
||
file_metadata = { | ||
'name' : os.path.basename(file_path), | ||
'parents' : [parent_folder_id] | ||
} | ||
file_metadata = {"name": os.path.basename(file_path), "parents": [parent_folder_id]} | ||
media = MediaFileUpload(file_path, resumable=True) | ||
file = service.files().create( | ||
body=file_metadata, | ||
media_body=media, | ||
fields='id' | ||
).execute() | ||
file = ( | ||
service.files() | ||
.create(body=file_metadata, media_body=media, fields="id") | ||
.execute() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.