Skip to content

Commit

Permalink
Prepare for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
bum8hj committed Apr 6, 2024
1 parent 1a26f62 commit 8013bff
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
18 changes: 9 additions & 9 deletions src/posts/static/posts/detail.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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')
}
Expand Down Expand Up @@ -65,7 +65,7 @@ $.ajax({
spinnerBox.classList.add('not-visible')
},
error: function(error) {
console.log(error)
//console.log(error)
}
})

Expand All @@ -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)
}
})
})
Expand All @@ -110,7 +110,7 @@ deleteForm.addEventListener('submit', (e) => {
localStorage.setItem('title', titleInput.value)
},
error: function(error) {
console.log(error)
//console.log(error)
}
})
})
18 changes: 9 additions & 9 deletions src/posts/static/posts/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console.log("hello world")
//console.log("hello world")

const DZ_MAXFILES = 3
const DZ_MAXFILE_SIZE_MB = 4
Expand Down Expand Up @@ -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)
}
})
}))
Expand All @@ -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 += `
<div class="card mb-3">
Expand Down Expand Up @@ -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.'
Expand All @@ -120,7 +120,7 @@ const getData = () => {
}
},
error: function(error) {
console.log(error)
//console.log(error)
}
})
}
Expand Down Expand Up @@ -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', `
<div class="card mb-2">
Expand Down Expand Up @@ -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!')
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/posts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions src/posts_proj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions src/profiles/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions src/profiles/static/profiles/main.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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 = `
<img src="${response.avatar}" class="rounded" height="200px" width="auto" alt="${response.user.username}">
`
Expand All @@ -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,
Expand Down

0 comments on commit 8013bff

Please sign in to comment.