diff --git a/diaryProject/Account/static/index.css b/diaryProject/Account/static/index.css new file mode 100644 index 0000000..80cf274 --- /dev/null +++ b/diaryProject/Account/static/index.css @@ -0,0 +1,6 @@ +img { + max-width: 200px; + max-height: 200px; + margin: 0 auto; + border-radius: 50%; +} \ No newline at end of file diff --git a/diaryProject/Account/static/signup.css b/diaryProject/Account/static/signup.css new file mode 100644 index 0000000..c3f0122 --- /dev/null +++ b/diaryProject/Account/static/signup.css @@ -0,0 +1,30 @@ + + +.login_btn { + width: 100px; + height: 40px; + left: 68px; + top: 505px; + background: #896AC9; + border-radius: 12px; + border: 0px; + font-weight: bolder; + color: white; + font-size: 20px; +} + +.signup_btn { + display: flex; + justify-content: center; +} + +.signup { + text-decoration: underline; + text-underline-position: under; + text-decoration-color: #896AC9; + margin-left: -150px; +} + +.login { + color: #A5ADB2; +} \ No newline at end of file diff --git a/diaryProject/Account/templates/index.html b/diaryProject/Account/templates/index.html new file mode 100644 index 0000000..33d8f87 --- /dev/null +++ b/diaryProject/Account/templates/index.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} +{% load static %} +{% block style %} +{% comment %} 여기에 연결할 css 추가 {% endcomment %} +{% endblock style %} +{% block js %} +{% comment %} 여기에 연결할 js - - - + + + + + + +{% endblock content %} diff --git a/diaryProject/MyPage/urls.py b/diaryProject/MyPage/urls.py index 176f39d..5e26ba7 100644 --- a/diaryProject/MyPage/urls.py +++ b/diaryProject/MyPage/urls.py @@ -20,5 +20,6 @@ urlpatterns = [ - path('', MyPage.views.mypage, name='mypage'), -] + path('main', MyPage.views.MainMypage, name='mypage'), + path('/', MyPage.views.calendar, name='calendar'), +] \ No newline at end of file diff --git a/diaryProject/MyPage/views.py b/diaryProject/MyPage/views.py index 538cc1e..273a98f 100644 --- a/diaryProject/MyPage/views.py +++ b/diaryProject/MyPage/views.py @@ -1,5 +1,28 @@ from django.shortcuts import render +from django.views.decorators.csrf import csrf_exempt +from django.contrib.auth.decorators import login_required +from diaryApp.models import Diary +from datetime import datetime +import json +def MainMypage(request): + today = datetime.now().date() + # startdate = str(today.year) + '-' + str(today.month).zfill(2) + '-' + '01' + # enddate = str(today.year) + '-' + str(today.month).zfill(2) + '-' + '31' + + my_diary = Diary.objects.filter( + creator = request.user, + diary_created_at__month = today.month + ) + + total = my_diary.count() + return render(request, 'mypage.html', {'diarys' : my_diary, 'total':total}) + +@csrf_exempt +@login_required(login_url='/registration/login') +def calendar(request, YearLooking, MonthLooking): + + + # print(YearLooking) + # print(MonthLooking) -# Create your views here. -def mypage(request): return render(request, 'mypage.html') \ No newline at end of file diff --git a/diaryProject/db.sqlite3 b/diaryProject/db.sqlite3 index 4b0c5ba..81b0466 100644 Binary files a/diaryProject/db.sqlite3 and b/diaryProject/db.sqlite3 differ diff --git a/diaryProject/diaryApp/static/css/background.css b/diaryProject/diaryApp/static/css/background.css new file mode 100644 index 0000000..6eaee5f --- /dev/null +++ b/diaryProject/diaryApp/static/css/background.css @@ -0,0 +1,15 @@ +#background-container { + height: 100%; + width: 100%; + background-color: #161b39; + position: relative; +} + +canvas { + position: absolute; + height: 100%; + width: 100%; + top: 0; + left: 0; + z-index: 0; +} diff --git a/diaryProject/diaryApp/static/css/fishing.css b/diaryProject/diaryApp/static/css/fishing.css index e1b41c8..3560153 100644 --- a/diaryProject/diaryApp/static/css/fishing.css +++ b/diaryProject/diaryApp/static/css/fishing.css @@ -9,7 +9,11 @@ align-items: center; } - +.navigator { + position: absolute; + top: 50px; + left: 300px; +} .astro { height: 50%; width: 100%; @@ -93,6 +97,10 @@ margin-left: 20px; font-size: 21px; } +.random-diary-header p { + margin-left: 20px; + font-size: 18px; +} .random-diary-content { height: 500.5px; width: 100%; diff --git a/diaryProject/diaryApp/static/css/index.css b/diaryProject/diaryApp/static/css/index.css index 271135e..25f236e 100644 --- a/diaryProject/diaryApp/static/css/index.css +++ b/diaryProject/diaryApp/static/css/index.css @@ -15,212 +15,224 @@ body { } */ * { - font-family: 'Laila', sans-serif; + font-family: "Laila", sans-serif; } .modal { - background-image: url("http://localhost:8000/static/img/diary-border.svg"); - background-repeat: no-repeat; - background-position: center; - background-size: contain; + background-image: url("http://localhost:8000/static/img/diary-border.svg"); + background-repeat: no-repeat; + background-position: center; + background-size: contain; } .modal-container { - background: linear-gradient(180deg, #6F46A7 0%, #896AC9 33.85%, #C99DDD 91.15%); + background: linear-gradient( + 180deg, + #6f46a7 0%, + #896ac9 33.85%, + #c99ddd 91.15% + ); } - .container { - width: 100%; - height: 100%; - position: absolute; - z-index: 1; + width: 100%; + height: 100%; + position: absolute; + z-index: 1; } .btn_register button { - width: 246px; - height: 57px; - background: linear-gradient(90deg, #234567 0%, #345678 44.65%, #456789 91.21%); - border-radius: 12px; - border: 0px; - font-weight: bolder; - color: white; - font-size: 20px; - + width: 246px; + height: 57px; + background: linear-gradient( + 90deg, + #234567 0%, + #345678 44.65%, + #456789 91.21% + ); + border-radius: 12px; + border: 0px; + font-weight: bolder; + color: white; + font-size: 20px; } .navbar_logo { - margin-top: -10px; + margin-top: -10px; } .btn_register { - margin-left: 63px; - margin-top: 250px; + margin-left: 63px; + margin-top: 250px; } .shadow { - box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); + box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); } - .bg-white { - background-color: rgb(255, 255, 255); + background-color: rgb(255, 255, 255); } .bg-btn { - background-color: #896AC9; + background-color: #896ac9; } .text-center { - text-align: center; + text-align: center; } .flex { - /* display: flex; */ - /* left : 90%; + /* display: flex; */ + /* left : 90%; right: 50%; */ - /* justify-content: center; + /* justify-content: center; flex-direction: column; align-content: center; align-items: center; */ - /* top : 50%; + /* top : 50%; bottom: 50%; */ - font-size: 1em; - z-index: 2; + font-size: 1em; + z-index: 2; } .modal-container { - z-index: 2; + z-index: 2; } -.form-inner{ - display: flex; - flex-direction: column; - padding-left: 40px; - padding-top: 15px; +.form-inner { + display: flex; + flex-direction: column; + padding-left: 40px; + padding-top: 15px; } .createDiary { - display: flex; - flex-direction: column; + display: flex; + flex-direction: column; } -.todoadd{ - display: flex; - flex-direction: column; +.todoadd { + display: flex; + flex-direction: column; } -.todo-input{ - display: flex; - flex-direction: row; - z-index: 500; +.todo-input { + display: flex; + flex-direction: row; + z-index: 500; } - .user_info { - color: white; - display: flex; - flex-direction: column; - justify-content: center; - width: 250px; + color: white; + display: flex; + flex-direction: column; + justify-content: center; + width: 250px; } .todo_group { - display: flex; - flex-direction:row; + display: flex; + flex-direction: row; } .user_info { - color: white; - display: flex; - flex-direction: row; - justify-content: space-between; - width: 250px; - margin-left: 9%; - margin-top: 7%; -} -.links{ - display: flex; - flex-direction: row; - justify-content: space-between; - width: 120px; - font-size: small; - margin-left: 85%; - margin-top: 1%; -} -.logouthref{ - margin-right: 10%; - margin: 6%; + color: white; + display: flex; + flex-direction: row; + justify-content: space-between; + width: 250px; + margin-left: 9%; + margin-top: 7%; +} +.links { + display: flex; + flex-direction: row; + justify-content: space-between; + width: 120px; + font-size: small; + margin-left: 85%; + margin-top: 1%; +} +.logouthref { + margin-right: 15%; } -.todo_group { - display: flex; - flex-direction:row; +.navbar-container { + position: absolute; + margin-right: 10px; } +.todo_group { + display: flex; + flex-direction: row; +} .navbar_menu_item { - width: 200px ; - position: absolute; + width: 200px; + position: absolute; } .user_info a { - position: absolute; - right: 50px; + position: absolute; + right: 50px; } .btn-open-modal { - width: 247px; - height: 57px; - color: white; - text-align: center; - align-items: center; + width: 247px; + height: 57px; + color: white; + text-align: center; + align-items: center; } .diary_write_btn { - font-family: 'Noto Serif KR', serif; + font-family: "Noto Serif KR", serif; } .modal-title { - font-size: 30px; - padding-top: 50px; - font-weight: bold; - color: #28104E; + font-size: 30px; + padding-top: 50px; + font-weight: bold; + color: #28104e; } h3 { - font-size: 23px; + font-size: 23px; } -input[type=text] { - width: 270px; - height: 150px; - font-family: 'Noto Serif KR', serif; - font-size: 12px; - border: 0; - border-radius: 15px; - outline: none; +input[type="text"] { + width: 270px; + height: 150px; + font-family: "Noto Serif KR", serif; + font-size: 12px; + border: 0; + border-radius: 15px; + outline: none; } .register_btn { - width: 20px; + width: 20px; } .diary button { - width: 70px; - height: 30px; - border-radius: 12px; - border: 0px; - font-family: 'Noto Serif KR', serif; - color: black; - font-size: 15px; - margin-top: 10px; - margin-left: 95px; + width: 70px; + height: 30px; + border-radius: 12px; + border: 0px; + font-family: "Noto Serif KR", serif; + color: black; + font-size: 15px; + margin-top: 10px; + margin-left: 95px; } -input{ - color: white; +input { + color: white; } input::placeholder { - color: white; - font-family: 'Noto Serif KR', serif; + color: white; + font-family: "Noto Serif KR", serif; } - +.navbar_container { + position:absolute; + right:10px; +} \ No newline at end of file diff --git a/diaryProject/diaryApp/static/img/LV1_fished.svg b/diaryProject/diaryApp/static/img/LV1_fished.svg index 884bdcc..c09560b 100644 --- a/diaryProject/diaryApp/static/img/LV1_fished.svg +++ b/diaryProject/diaryApp/static/img/LV1_fished.svg @@ -2,18 +2,23 @@ + - + - + - + - - - + + + + + + + diff --git a/diaryProject/diaryApp/static/img/earth.png b/diaryProject/diaryApp/static/img/earth.png new file mode 100644 index 0000000..3fdea02 Binary files /dev/null and b/diaryProject/diaryApp/static/img/earth.png differ diff --git a/diaryProject/diaryApp/static/img/planet1.png b/diaryProject/diaryApp/static/img/planet1.png new file mode 100644 index 0000000..e5c3498 Binary files /dev/null and b/diaryProject/diaryApp/static/img/planet1.png differ diff --git a/diaryProject/diaryApp/static/img/planet2.png b/diaryProject/diaryApp/static/img/planet2.png new file mode 100644 index 0000000..a704a97 Binary files /dev/null and b/diaryProject/diaryApp/static/img/planet2.png differ diff --git a/diaryProject/diaryApp/static/img/planet3.png b/diaryProject/diaryApp/static/img/planet3.png new file mode 100644 index 0000000..01cdeb5 Binary files /dev/null and b/diaryProject/diaryApp/static/img/planet3.png differ diff --git a/diaryProject/diaryApp/static/img/planet_special.png b/diaryProject/diaryApp/static/img/planet_special.png new file mode 100644 index 0000000..da76366 Binary files /dev/null and b/diaryProject/diaryApp/static/img/planet_special.png differ diff --git a/diaryProject/diaryApp/static/img/star1.png b/diaryProject/diaryApp/static/img/star1.png new file mode 100644 index 0000000..1029063 Binary files /dev/null and b/diaryProject/diaryApp/static/img/star1.png differ diff --git a/diaryProject/diaryApp/static/img/star2.png b/diaryProject/diaryApp/static/img/star2.png new file mode 100644 index 0000000..7672b84 Binary files /dev/null and b/diaryProject/diaryApp/static/img/star2.png differ diff --git a/diaryProject/diaryApp/static/img/star3.png b/diaryProject/diaryApp/static/img/star3.png new file mode 100644 index 0000000..7ce1f2e Binary files /dev/null and b/diaryProject/diaryApp/static/img/star3.png differ diff --git a/diaryProject/diaryApp/static/js/fishing.js b/diaryProject/diaryApp/static/js/fishing.js index c3a60a5..7f4070f 100644 --- a/diaryProject/diaryApp/static/js/fishing.js +++ b/diaryProject/diaryApp/static/js/fishing.js @@ -1,31 +1,31 @@ -const mainContainer = document.getElementById('main-container'); -const astro = document.getElementById('astro'); -const diaryElement = document.getElementById('random-diary'); +const mainContainer = document.getElementById("main-container"); +const astro = document.getElementById("astro"); +const diaryElement = document.getElementById("random-diary"); const showRandomDiary = () => { - astro.classList.add('hide'); - diaryElement.classList.remove('hide'); -} + astro.classList.add("hide"); + diaryElement.classList.remove("hide"); +}; const hideRandomDiary = () => { - astro.classList.remove('hide'); - diaryElement.classList.add('hide'); -} + astro.classList.remove("hide"); + diaryElement.classList.add("hide"); +}; let accelerometer = null; -if ('Accelerometer' in window) { - console.log('acc exist') +if ("Accelerometer" in window) { + console.log("acc exist"); } else { - console.log('no acc') + console.log("no acc"); } try { - accelerometer = new Accelerometer({frequency: 10}); + accelerometer = new Accelerometer({ frequency: 10 }); accelerometer.onerror = (event) => { - if (event.error.name === 'NotAllowedError') { - console.log('Permission to access sensor was denied.'); - } else if (event.error.name === 'NotReadableError') { - console.log('Cannot connect to the sensor.'); + if (event.error.name === "NotAllowedError") { + console.log("Permission to access sensor was denied."); + } else if (event.error.name === "NotReadableError") { + console.log("Cannot connect to the sensor."); } }; accelerometer.onreading = (e) => { @@ -33,11 +33,42 @@ try { }; accelerometer.start(); } catch (error) { - if (error.name === 'SecurityError') { - console.log('Sensor construction was blocked by the Permissions Policy.'); - } else if (error.name === 'ReferenceError') { - console.log('Sensor is not supported by the User Agent.'); + if (error.name === "SecurityError") { + console.log( + "Sensor construction was blocked by the Permissions Policy." + ); + } else if (error.name === "ReferenceError") { + console.log("Sensor is not supported by the User Agent."); } else { throw error; } -}; \ No newline at end of file +} + +let state = 0; +const fishingHandler = () => { + const astronaunt = document.getElementById("fishing"); + if (state <= 2) { + state++; + } + if (state === 0) { + astronaunt.src = "http://localhost:8000/static/img/LV1_fishing.svg"; + } else if (state === 1) { + astronaunt.src = "http://localhost:8000/static/img/LV1_fish.svg"; + } else if (state === 2) { + astronaunt.src = "http://localhost:8000/static/img/LV1_fished.svg"; + } else if (state === 3) { + showRandomDiary(); + state = 0; + astronaunt.src = "http://localhost:8000/static/img/LV1_fishing.svg"; + } +}; + +const getToday = () => { + const today = new Date(); + const year = today.getFullYear(); + const month = today.getMonth() + 1; + const date = today.getDate(); + + document.querySelector('.random-diary-header span').innerHTML = `${year}년 ${month}월 ${date}일`; +} +getToday(); \ No newline at end of file diff --git a/diaryProject/diaryApp/static/signup.css b/diaryProject/diaryApp/static/signup.css new file mode 100644 index 0000000..3aa1c5c --- /dev/null +++ b/diaryProject/diaryApp/static/signup.css @@ -0,0 +1,51 @@ +.container { + font-family: 'Laila', sans-serif; +} + +* { + margin: 0; + padding: 0; + } + + body { + font-family: 'Noto Sans KR', sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + } + + .login-form h1 { + font-size: 32px; + text-align: center; + margin-bottom: 50px; + } + + .int-area { + width: 400px; + position: relative; + margin-top: 20px; + } + + .int-area:first-child { + margin-top: 0; + } + + .int-area input { + width: 100%; + padding: 20px 10px 10px; + background-color: transparent; + border: none; + border-bottom: 1px solid black; + font-size: 18px; + outline: none; + } + + .int-area label { + position: absolute; + left: 10px; + top: 15px; + font-size: 18px; + transition: top 0.5s ease; + } + \ No newline at end of file diff --git a/diaryProject/diaryApp/templates/background.html b/diaryProject/diaryApp/templates/background.html new file mode 100644 index 0000000..dc92564 --- /dev/null +++ b/diaryProject/diaryApp/templates/background.html @@ -0,0 +1,16 @@ +{% extends 'base.html' %} +{% load static %} +{% block style %} +{% comment %} 여기에 연결할 css 추가 {% endcomment %} + +{% endblock style %} +{% block js %} +{% comment %} 여기에 연결할 js +{% endblock js %} +{% block content %} +
+ + +
+{% endblock content %} \ No newline at end of file diff --git a/diaryProject/diaryApp/templates/diaryApp/base.html b/diaryProject/diaryApp/templates/diaryApp/base.html new file mode 100644 index 0000000..364b723 --- /dev/null +++ b/diaryProject/diaryApp/templates/diaryApp/base.html @@ -0,0 +1,32 @@ + + + + + + + + snulion + {% load static %} + + {% block style %} {% endblock style %} + + + +
+ + {% block content %} {% endblock %} +
+ + + + + {% block js %} {% endblock js %} + + diff --git a/diaryProject/diaryApp/templates/fishing.html b/diaryProject/diaryApp/templates/fishing.html index 4954ce7..66f6451 100644 --- a/diaryProject/diaryApp/templates/fishing.html +++ b/diaryProject/diaryApp/templates/fishing.html @@ -10,24 +10,37 @@ {% endblock js %} {% block content %}
+
-
+
다른 우주인의
오늘은 어땠을까?
- +
- 00년 00월 00일
user의 일기
+
+ 00년 00월 00일 +

{{randomDiary.creator}}님의 일기

+
-

{{user.id}}님의 오늘의 Todo

+

{{randomDiary.creator}}님의 오늘의 Todo

+
    + {% for todo in randomDiary.todos %} +
  • {{todo}}
  • + {% endfor %} +

Q. 오늘 하루 중 가장 마음에 들었던 일은?

+ {{randomDiary.content}}
diff --git a/diaryProject/diaryApp/templates/index.html b/diaryProject/diaryApp/templates/index.html index a062c85..3ea81be 100644 --- a/diaryProject/diaryApp/templates/index.html +++ b/diaryProject/diaryApp/templates/index.html @@ -13,8 +13,8 @@ 안녕하세요, {{user.username}} 님!
diff --git a/diaryProject/diaryApp/templates/registration/login.html b/diaryProject/diaryApp/templates/registration/login.html new file mode 100644 index 0000000..6cecd54 --- /dev/null +++ b/diaryProject/diaryApp/templates/registration/login.html @@ -0,0 +1,32 @@ +{% load static %} + + + + + + + + Login + + + +
+
+
+ {% csrf_token %} {% if error %} +

{{error}}

+ {% endif %} + +
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/diaryProject/diaryApp/templates/registration/signup.html b/diaryProject/diaryApp/templates/registration/signup.html new file mode 100644 index 0000000..a5892cf --- /dev/null +++ b/diaryProject/diaryApp/templates/registration/signup.html @@ -0,0 +1,43 @@ +{% load static %} + + + + + + + + + + + Document + + + + +
+
+ {% csrf_token %} + {% if error %} +

{{error}}

+ {% endif %} +

Login

+
+
+ + +
+
+ + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/diaryProject/diaryApp/views.py b/diaryProject/diaryApp/views.py index 0162cfa..7930ec7 100644 --- a/diaryProject/diaryApp/views.py +++ b/diaryProject/diaryApp/views.py @@ -4,37 +4,9 @@ from .models import Diary from django.views.decorators.csrf import csrf_exempt from django.http import JsonResponse +from random import randint # Create your views here. -def signup(request): - if request.method == "POST": - username = request.POST["username"] - password = request.POST["password"] - found_user = User.objects.filter(username=username) - if len(found_user): - error = "이미 존재하는 아이디입니다." - return render(request, "registration/signup.html", {"error": error}) - new_user = User.objects.create_user(username=username, password=password) - auth.login(request, new_user) - return redirect("index") - - return render(request, "registration/signup.html") - - -def login(request): - if request.method == "POST": - username=request.POST['username'] - password = request.POST['password'] - user = auth.authenticate(request, username=username, password=password) - if user is not None: - auth.login(request, user) - return redirect("index") - error = "아이디 혹은 비밀번호가 틀립니다." - return render(request, "registration/login.html", {"error": error}) - - return render(request, "registration/login.html") - - def logout(request): auth.logout(request) @@ -44,7 +16,11 @@ def index(request): return render(request, 'index.html') def fishing(request): - return render(request, 'fishing.html') + user = request.user + diaryList = Diary.objects.exclude(creator=user.id) + rand = randint(0, len(diaryList)-1) + randomDiary = diaryList[rand] + return render(request, 'fishing.html', {'randomDiary': randomDiary}) def background(request): return render(request, 'background.html')