Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

프로필 정보 입력기능 추가 #13

Open
wants to merge 2 commits into
base: main2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified runningmate/db.sqlite3
Binary file not shown.
Binary file modified runningmate/mateapp/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/mateapp/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/mateapp/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/mateapp/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/mateapp/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/mateapp/__pycache__/views.cpython-39.pyc
Binary file not shown.
74 changes: 74 additions & 0 deletions runningmate/mateapp/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from django import forms
from .models import Post, Comment, FreePost, FreeComment

class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = '__all__'

def __init__(self, *args, **kwargs):
super(PostForm, self).__init__(*args, **kwargs)
# 여기서 폼 추가하면 될 듯 싶은데
self.fields['title'].widget.attrs = {
'class': 'form-control',
'placeholder': "강의명을 입력해주세요", # 입력 전 나오는 문구
'rows': 20
}

self.fields['body'].widget.attrs = {
'class': 'form-control',
'placeholder': "글 제목을 입력해주세요",
'rows': 20,
'cols' : 100
}


class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ['comment']

def __init__(self, *args, **kwargs):
super(CommentForm, self).__init__(*args, **kwargs)

self.fields['comment'].widget.attrs = {
'class': 'form-control',
'placeholder': "댓글을 입력해주세요",
'rows': 10
}

# class FreePostForm(forms.ModelForm):
# class Meta:
# model = FreePost
# fields = ['title', 'body']

# def __init__(self, *args, **kwargs):
# super(FreePostForm, self).__init__(*args, **kwargs)

# self.fields['title'].widget.attrs = {
# 'class': 'form-control',
# 'placeholder': "글 제목을 입력해주세요",
# 'rows': 20
# }

# self.fields['body'].widget.attrs = {
# 'class': 'form-control',
# 'placeholder': "글 제목을 입력해주세요",
# 'rows': 20,
# 'cols' : 100
# }


class FreeCommentForm(forms.ModelForm):
class Meta:
model = FreeComment
fields = ['comment']

def __init__(self, *args, **kwargs):
super(FreeCommentForm, self).__init__(*args, **kwargs)

self.fields['comment'].widget.attrs = {
'class': 'form-control',
'placeholder': "댓글을 입력해주세요",
'rows': 10
}
Binary file not shown.
Binary file not shown.
29 changes: 19 additions & 10 deletions runningmate/mateapp/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from statistics import mode
from django.db import models
from django.contrib.auth.models import User

Expand All @@ -11,15 +12,23 @@ class Post(models.Model):
body = models.TextField()
image = models.ImageField(upload_to = "post/", blank=True, null=True)

def __str__(self):
return self.title
def __str__(self):
return self.title

def summary(self):
return self.body[:10]

class Post(models.Model):
userName = models.CharField(max_length=20) # 이름 입력 최대 20글자
userAbility = models.CharField(max_length=20) # 이름 입력 최대 20글자
writer = models.ForeignKey(User,on_delete=models.CASCADE) # 작성자 누군지
pub_date = models.DateTimeField()
body = models.TextField()
image = models.ImageField(upload_to = "post/", blank=True, null=True)
def __str__(self):
return self.title

def summary(self):
return self.body[:10]

def summary(self):
return self.body[:10]

class Comment(models.Model):
content = models.TextField()
writer = models.ForeignKey(User, on_delete=models.CASCADE)
post = models.ForeignKey(Post ,on_delete=models.CASCADE, related_name ='comments')
created_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
8 changes: 8 additions & 0 deletions runningmate/mateapp/templates/mateapp/calendarDay.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- 페이지네이션
{% if posts.has_previous %}
여기 아래마다
<a href="?page=1"></a>
<a href="?page={{posts.previous_page_number}}">이전 페이지</a>


{% endblock %}
12 changes: 12 additions & 0 deletions runningmate/mateapp/templates/mateapp/createDay_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'base.html' %}
{% block content %}

<form action="" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<table>
{{form.as_p}}
</table>
<br/>
<input type="submit" value="create">
</form>
{% endblock %}
13 changes: 13 additions & 0 deletions runningmate/mateapp/templates/mateapp/create_my_profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'base.html' %}
{% load static %}

{% block content %}

<form action="캘린더 입력값 보낼 곳 템플릿 url" method="POST">
{%csrf_token%}
<p>닉네임 : <input type="text" name="userName"></p>
<p>선호 파트 : <input type="text" name="ability"></p>
<p>선호시간대 : <input type="text" name="favorTime"></p>
<p>MBTI : <input type="text" name="MBTI"></p>
<p>나를 표현하는 해시태그<input type="checkbox" name="hashTag"></p>
</form>
2 changes: 1 addition & 1 deletion runningmate/mateapp/templates/mateapp/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<p><input type="password" name="password" placeholder=" 비밀번호" autocomplete="current-password" required="" id="login_password"></p>
<input id="login_submit" type="submit" value="로그인하기"></p>
<a href="{% url 'account_signup' %}">회원가입</a>
<a href="{% provider_login_url 'google' %}">구글
<a href="{% provider_login_url 'google' %}">구글</a>
</form>
</div>
2 changes: 2 additions & 0 deletions runningmate/mateapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
urlpatterns = [
path('mainpage',showmain, name = "showmain"),
path('calendar',calendar, name = "calendar"),
path('detail/<int:id>', detail, name = "detail"), # 아마 여기를 페이지 넘버별로 일정이 달라지는 식으로 구현하고 싶긴한데 ..
path('', login, name="login"),
path('create_my_profile', create,name="create"),
]
29 changes: 28 additions & 1 deletion runningmate/mateapp/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from django.contrib import auth
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.shortcuts import render, redirect
from django.shortcuts import render, redirect, get_object_or_404
from django.core.paginator import Paginator
from .models import Post

# Create your views here.
def showmain(request):
posts = Post.objects.all() # models.py에 저장된 모든 객체를 posts 에 저장함
return render(request,'mateapp/mainpage.html')

def login(request):
Expand All @@ -12,5 +16,28 @@ def login(request):
else:
return render(request, 'mateapp/login.html')

def create(request):
new_post = Post()
new_post.userName = request.POST['userName']
new_post.userAbility = request.POST['userAbility']
new_post.body = request.POST['body']
new_post.save()
return redirect('detail', new_post,id)


def detail(request, id):
post = get_object_or_404(Post, pk = id)
return render(request, 'mateapp/detail.html', {'post':post})

def calendar(request):
return render(request,'mateapp/calendar.html')


# 일짜별 캘린더 페이지 네이터
def calendarDay(request): # 캘린더에 + 추가 하면 각 일자마다 페이지를 이동시켜버림
# posts = Post.objects.all()
posts = Post.objects.filter().order_by('-date') # posts는 객체들의 목록임
paginator = Paginator(posts,1) # 하루씩 입력받아 페이지를 넘긴다는 뜻임
pagnum = request.GET.get('page') # 페이지에 해당하는 밸류의 키값을 반환하기 위해서 GET 요청을 함
posts = paginator.get_page(pagnum) # 페이지네이터에서 짜른 객체가 posts에 요청이 갈꺼고, 담길것임
return render(request, 'calenderDay.html', {'posts':posts})
Binary file modified runningmate/runningmate/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/runningmate/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/runningmate/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified runningmate/runningmate/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
15 changes: 0 additions & 15 deletions runningmate/runningmate/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
"""runningmate URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from mateapp import views
Expand Down
9 changes: 0 additions & 9 deletions runningmate/runningmate/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
"""
WSGI config for runningmate project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
Expand Down