Small cleanups
This commit is contained in:
1 parent
5ae64025aa
commit
b5b95ec9cf
5 files changed
+64
-53
No files matched your search
+10
-10
@@ -200,32 +200,32 @@ def profile(request):
|
||||
|
||||
return django.http.HttpResponseRedirect('/index/')
|
||||
|
||||
def profileConfig(request):
|
||||
def profile_config(request):
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
return django.http.HttpResponseRedirect('/login/')
|
||||
|
||||
|
||||
if request.method == 'GET':
|
||||
return render(request, 'profile.html')
|
||||
|
||||
profile = Profile.objects.filter(user=request.user)
|
||||
profile = profile.first()
|
||||
profile = Profile.objects.get(user=request.user)
|
||||
|
||||
changes = False # To check if any changes are made.
|
||||
|
||||
|
||||
default_status = request.POST.get('default-status', '')
|
||||
|
||||
if default_status != '':
|
||||
# update the default engine
|
||||
profile.engine = default_status
|
||||
changes = True
|
||||
|
||||
|
||||
deleted_repos = request.POST.get('deleted-repos', '[]')
|
||||
deleted_repos_array = json.loads(deleted_repos)
|
||||
|
||||
for engine in deleted_repos_array:
|
||||
if engine in profile.repos:
|
||||
del profile.repos[engine]
|
||||
|
||||
|
||||
if len(deleted_repos_array) != 0:
|
||||
changes = True
|
||||
|
||||
@@ -237,15 +237,15 @@ def profileConfig(request):
|
||||
elif request.POST['new-engine-name'] != "None" and request.POST['new-engine-repo'].startswith('https://github.com/'):
|
||||
engine_name = request.POST['new-engine-name']
|
||||
engine_repo = request.POST['new-engine-repo']
|
||||
|
||||
|
||||
# Append the new engine and repo to the profile's repos field
|
||||
profile.repos[engine_name] = engine_repo
|
||||
changes = True
|
||||
|
||||
|
||||
if changes:
|
||||
profile.save() # Save if any changes are made
|
||||
|
||||
return django.http.HttpResponseRedirect('/index/')
|
||||
return render(request, 'profile.html')
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# TEST LIST VIEWS #
|
||||
|
||||
Reference in new issue
Block a user