SushantGautam commited on
Commit
d9b93e7
·
1 Parent(s): a44ad18

Update cache directory in refresh_author_db function and modify response in refresh_author_db_view for admin access

Browse files
Files changed (3) hide show
  1. .gitignore +2 -1
  2. BridgeMentor/utils.py +1 -1
  3. core/views.py +2 -2
.gitignore CHANGED
@@ -2,4 +2,5 @@
2
  venv
3
  migrations
4
  db.sqlite3*
5
- staticfiles
 
 
2
  venv
3
  migrations
4
  db.sqlite3*
5
+ staticfiles
6
+ .cache
BridgeMentor/utils.py CHANGED
@@ -15,7 +15,7 @@ def refresh_author_db(check_time=False):
15
  repo_id="SushantGautam/BridgeMentor",
16
  filename="db.sqlite3",
17
  repo_type="dataset",
18
- cache_dir=custom_cache_dir
19
  )
20
  print(f"Downloaded to: {file_path}")
21
  shutil.copy(file_path, db_file)
 
15
  repo_id="SushantGautam/BridgeMentor",
16
  filename="db.sqlite3",
17
  repo_type="dataset",
18
+ cache_dir=custom_cache_dir+"/.cache",
19
  )
20
  print(f"Downloaded to: {file_path}")
21
  shutil.copy(file_path, db_file)
core/views.py CHANGED
@@ -1,5 +1,5 @@
1
  from .models import Domain, Field, Subfield, Topic
2
- from django.http import JsonResponse
3
  from django.shortcuts import render
4
 
5
  from BridgeMentor.utils import refresh_author_db
@@ -14,7 +14,7 @@ def refresh_author_db_view(request):
14
  if not request.user.is_superuser:
15
  return JsonResponse({"error": "Permission denied"}, status=403)
16
  refresh_author_db(check_time=False)
17
- return JsonResponse({"status": "success", "message": "Database refreshed successfully. <a href='/'>Go Home</a>"}, status=200)
18
 
19
 
20
  def search_hierarchy(request):
 
1
  from .models import Domain, Field, Subfield, Topic
2
+ from django.http import JsonResponse, HttpResponse
3
  from django.shortcuts import render
4
 
5
  from BridgeMentor.utils import refresh_author_db
 
14
  if not request.user.is_superuser:
15
  return JsonResponse({"error": "Permission denied"}, status=403)
16
  refresh_author_db(check_time=False)
17
+ return HttpResponse("Database refreshed successfully. <a href='/'>Go Home</a>", status=200)
18
 
19
 
20
  def search_hierarchy(request):