From 8013bff25ad8235343f9291bdbbd550674c8b5f5 Mon Sep 17 00:00:00 2001 From: JessePinkman Date: Sat, 6 Apr 2024 19:18:57 -0400 Subject: [PATCH] Prepare for deployment --- src/posts/static/posts/detail.js | 18 +++++++++--------- src/posts/static/posts/main.js | 18 +++++++++--------- src/posts/utils.py | 4 ++-- src/posts_proj/settings.py | 7 +++++-- src/profiles/signals.py | 6 +++--- src/profiles/static/profiles/main.js | 6 +++--- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/posts/static/posts/detail.js b/src/posts/static/posts/detail.js index e89bf88..b3f8e34 100644 --- a/src/posts/static/posts/detail.js +++ b/src/posts/static/posts/detail.js @@ -1,5 +1,5 @@ -console.log("hello world detail") -console.log(window.location.href) +//console.log("hello world detail") +//console.log(window.location.href) const postBox = document.getElementById('post-box') const alertBox = document.getElementById('alert-box') @@ -28,13 +28,13 @@ $.ajax({ type: 'GET', url: url, success: function(response) { - console.log(response) + //console.log(response) const data = response.data if (data.logged_in !== data.author) { - console.log('different') + //console.log('different') } else { - console.log('the same') + //console.log('the same') updateBtn.classList.remove('not-visible') deleteBtn.classList.remove('not-visible') } @@ -65,7 +65,7 @@ $.ajax({ spinnerBox.classList.add('not-visible') }, error: function(error) { - console.log(error) + //console.log(error) } }) @@ -84,14 +84,14 @@ updateForm.addEventListener('submit', (e) => { 'body': bodyInput.value }, success: function(response) { - console.log(response) + //console.log(response) handleAlerts('success', 'Post updated.') title.textContent = response.title body.textContent = response.body }, error: function(error) { - console.log(error) + //console.log(error) } }) }) @@ -110,7 +110,7 @@ deleteForm.addEventListener('submit', (e) => { localStorage.setItem('title', titleInput.value) }, error: function(error) { - console.log(error) + //console.log(error) } }) }) \ No newline at end of file diff --git a/src/posts/static/posts/main.js b/src/posts/static/posts/main.js index e31096a..81f3a05 100644 --- a/src/posts/static/posts/main.js +++ b/src/posts/static/posts/main.js @@ -1,4 +1,4 @@ -console.log("hello world") +//console.log("hello world") const DZ_MAXFILES = 3 const DZ_MAXFILE_SIZE_MB = 4 @@ -59,11 +59,11 @@ const likeUnlikePosts = () => { 'pk': clickedId }, success: function(response) { - console.log(response) + //console.log(response) clickedBtn.textContent = (response.liked ? "Unlike" : "Like") + ` (${response.like_count})` }, error: function(error) { - console.log(error) + //console.log(error) } }) })) @@ -76,12 +76,12 @@ const getData = () => { type: 'GET', url: `/data/${visible}/`, success: function(response) { - console.log(response) + //console.log(response) const data = response.data setTimeout(() => { spinnerBox.classList.add('not-visible') - console.log(data) + //console.log(data) data.forEach(el => { postsBox.innerHTML += `
@@ -109,7 +109,7 @@ const getData = () => { likeUnlikePosts() }, 100) - console.log(response.size) + //console.log(response.size) if (response.size === 0) { endBox.textContent = 'No posts added yet.' @@ -120,7 +120,7 @@ const getData = () => { } }, error: function(error) { - console.log(error) + //console.log(error) } }) } @@ -155,7 +155,7 @@ postForm.addEventListener('submit', e => { 'body': body.value }, success: function(response) { - console.log(response) + //console.log(response) newPostId = response.id postsBox.insertAdjacentHTML('afterbegin', `
@@ -184,7 +184,7 @@ postForm.addEventListener('submit', e => { //postForm.reset() }, error: function(error) { - console.log(error) + //console.log(error) handleAlerts('danger', 'Oops, something went wrong!') } }) diff --git a/src/posts/utils.py b/src/posts/utils.py index 2230618..5dfc81d 100644 --- a/src/posts/utils.py +++ b/src/posts/utils.py @@ -9,10 +9,10 @@ def wrapper(request, **kwargs): post = Post.objects.get(pk=pk) if profile.user == post.author.user: - print('You are the author') + #print('You are the author') return func(request, **kwargs) else: - print('You are not the author') + #print('You are not the author') return redirect('posts:main-board') return wrapper \ No newline at end of file diff --git a/src/posts_proj/settings.py b/src/posts_proj/settings.py index 872a86f..0c4010c 100644 --- a/src/posts_proj/settings.py +++ b/src/posts_proj/settings.py @@ -23,9 +23,11 @@ SECRET_KEY = 'django-insecure-uj8*tak7nw*0bt#947^zl69=ux7gzwc-lai(zu98ogc0^!+%u$' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = [ + 'http://bum8hj123.pythonanywhere.com/' +] # Application definition @@ -125,6 +127,7 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.0/howto/static-files/ +STATIC_ROOT = BASE_DIR / 'staticFiles' STATIC_URL = 'static/' STATICFILES_DIRS = [ BASE_DIR / 'static', diff --git a/src/profiles/signals.py b/src/profiles/signals.py index 8cbb50c..45cf0fb 100644 --- a/src/profiles/signals.py +++ b/src/profiles/signals.py @@ -5,9 +5,9 @@ @receiver(post_save, sender=User) def post_save_create_profile(sender, instance, created, *args, **kwargs): - print(sender) - print(instance) - print(created) + #print(sender) + #print(instance) + #print(created) if created: Profile.objects.create(user=instance) else: diff --git a/src/profiles/static/profiles/main.js b/src/profiles/static/profiles/main.js index 4e513d9..cca11a1 100644 --- a/src/profiles/static/profiles/main.js +++ b/src/profiles/static/profiles/main.js @@ -1,4 +1,4 @@ -console.log('hello my profile') +//console.log('hello my profile') const avatarBox = document.getElementById('avatar-box') const alertBox = document.getElementById('alert-box') @@ -23,7 +23,7 @@ profileForm.addEventListener('submit', e => { enctype: 'multipart/form-data', data: formData, success: function(response) { - console.log(response) + //console.log(response) avatarBox.innerHTML = ` ${response.user.username} ` @@ -32,7 +32,7 @@ profileForm.addEventListener('submit', e => { handleAlerts('success', 'Profile updated.') }, error: function(error) { - console.log(error) + //console.log(error) }, processData: false, contentType: false,