Spaces:
Sleeping
Sleeping
thejagstudio
commited on
Commit
•
41fef54
1
Parent(s):
9b9f897
Update home/views.py
Browse files- home/views.py +20 -8
home/views.py
CHANGED
@@ -137,12 +137,12 @@ def list(request):
|
|
137 |
list_files = DRIVE.ListFile({'q': "'%s' in parents and trashed=false" % folder_id}).GetList()
|
138 |
for file in list_files:
|
139 |
if file['title'] != 'Deleted' and file['title'] != 'DeletedFile' and file['mimeType'] != 'application/vnd.google-apps.folder':
|
140 |
-
files.append([file['title'], file['embedLink']])
|
141 |
elif file['mimeType'] == 'application/vnd.google-apps.folder':
|
142 |
folders.append([file['title'], "/list/"+file['id'][::-1]])
|
143 |
else:
|
144 |
pass
|
145 |
-
context = {'files': files, 'folders': folders}
|
146 |
return render(request, 'list.html', context=context)
|
147 |
|
148 |
|
@@ -155,13 +155,13 @@ def folder_list(request, id):
|
|
155 |
list_files = DRIVE.ListFile({'q': "'%s' in parents and trashed=false" % folder_id}).GetList()
|
156 |
for file in list_files:
|
157 |
if file['title'] != 'Deleted' and file['mimeType'] != 'application/vnd.google-apps.folder':
|
158 |
-
files.append([file['title'], file['embedLink']])
|
159 |
elif file['mimeType'] == 'application/vnd.google-apps.folder':
|
160 |
folders.append([file['title'], "/list/"+file['id'][::-1]])
|
161 |
else:
|
162 |
pass
|
163 |
-
context = {'files': files, 'folders': folders}
|
164 |
-
return render(request, '
|
165 |
|
166 |
|
167 |
@csrf_exempt
|
@@ -169,11 +169,21 @@ def folder_list(request, id):
|
|
169 |
def deleteFile(request):
|
170 |
if request.method == 'POST':
|
171 |
file_id = json.loads(request.body)['file_id']
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
file = DRIVE.CreateFile({'id': file_id})
|
174 |
file.FetchMetadata(fields="title")
|
175 |
-
file['title'] =
|
176 |
-
file.SetContentString('')
|
177 |
file.Upload()
|
178 |
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
179 |
|
@@ -193,6 +203,7 @@ def emailSender(request):
|
|
193 |
send_mail(subject, message, from_email, [to_email], fail_silently=True)'''
|
194 |
return redirect('index')
|
195 |
|
|
|
196 |
def ipGetter(request):
|
197 |
ip = request.GET.get('ip', '')
|
198 |
ipIn = ip_address.objects.filter(ip=ip).first()
|
@@ -217,3 +228,4 @@ def godMode(request):
|
|
217 |
folium.Marker(myAddress).add_to(my_map1)
|
218 |
my_map1.save('templates/godMode.html')
|
219 |
return render(request, 'godMode.html')
|
|
|
|
137 |
list_files = DRIVE.ListFile({'q': "'%s' in parents and trashed=false" % folder_id}).GetList()
|
138 |
for file in list_files:
|
139 |
if file['title'] != 'Deleted' and file['title'] != 'DeletedFile' and file['mimeType'] != 'application/vnd.google-apps.folder':
|
140 |
+
files.append([file['title'], file['embedLink'], file['id'], file["iconLink"].replace("/16/", "/32/"), file["webContentLink"]])
|
141 |
elif file['mimeType'] == 'application/vnd.google-apps.folder':
|
142 |
folders.append([file['title'], "/list/"+file['id'][::-1]])
|
143 |
else:
|
144 |
pass
|
145 |
+
context = {'files': files, 'folders': folders, 'back': False}
|
146 |
return render(request, 'list.html', context=context)
|
147 |
|
148 |
|
|
|
155 |
list_files = DRIVE.ListFile({'q': "'%s' in parents and trashed=false" % folder_id}).GetList()
|
156 |
for file in list_files:
|
157 |
if file['title'] != 'Deleted' and file['mimeType'] != 'application/vnd.google-apps.folder':
|
158 |
+
files.append([file['title'], file['embedLink'], file['id'], file["iconLink"].replace("/16/", "/32/"), file["webContentLink"]])
|
159 |
elif file['mimeType'] == 'application/vnd.google-apps.folder':
|
160 |
folders.append([file['title'], "/list/"+file['id'][::-1]])
|
161 |
else:
|
162 |
pass
|
163 |
+
context = {'files': files, 'folders': folders, 'back': True}
|
164 |
+
return render(request, 'list.html', context=context)
|
165 |
|
166 |
|
167 |
@csrf_exempt
|
|
|
169 |
def deleteFile(request):
|
170 |
if request.method == 'POST':
|
171 |
file_id = json.loads(request.body)['file_id']
|
172 |
+
file = DRIVE.CreateFile({'id': file_id})
|
173 |
+
file.Trash()
|
174 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
175 |
+
|
176 |
+
|
177 |
+
@csrf_exempt
|
178 |
+
@login_required
|
179 |
+
def renameFile(request):
|
180 |
+
if request.method == 'POST':
|
181 |
+
data = json.loads(request.body)
|
182 |
+
file_id = data['file_id']
|
183 |
+
new_name = data['new_name']
|
184 |
file = DRIVE.CreateFile({'id': file_id})
|
185 |
file.FetchMetadata(fields="title")
|
186 |
+
file['title'] = new_name
|
|
|
187 |
file.Upload()
|
188 |
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
189 |
|
|
|
203 |
send_mail(subject, message, from_email, [to_email], fail_silently=True)'''
|
204 |
return redirect('index')
|
205 |
|
206 |
+
|
207 |
def ipGetter(request):
|
208 |
ip = request.GET.get('ip', '')
|
209 |
ipIn = ip_address.objects.filter(ip=ip).first()
|
|
|
228 |
folium.Marker(myAddress).add_to(my_map1)
|
229 |
my_map1.save('templates/godMode.html')
|
230 |
return render(request, 'godMode.html')
|
231 |
+
|