diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3261c21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,216 @@ +# Created by https://www.toptal.com/developers/gitignore/api/django,python +# Edit at https://www.toptal.com/developers/gitignore?templates=django,python + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# Cython debug symbols + +# End of https://www.toptal.com/developers/gitignore/api/django,python \ No newline at end of file diff --git a/mysite/manage.py b/mysite/manage.py new file mode 100644 index 0000000..a7da667 --- /dev/null +++ b/mysite/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/mysite/mysite/__init__.py b/mysite/mysite/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mysite/mysite/asgi.py b/mysite/mysite/asgi.py new file mode 100644 index 0000000..451affb --- /dev/null +++ b/mysite/mysite/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for mysite project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') + +application = get_asgi_application() diff --git a/mysite/mysite/settings.py b/mysite/mysite/settings.py new file mode 100644 index 0000000..4ce401c --- /dev/null +++ b/mysite/mysite/settings.py @@ -0,0 +1,129 @@ +""" +Django settings for mysite project. + +Generated by 'django-admin startproject' using Django 3.1.7. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '-nhm^l^vj@i61gn2-&6ob(xc!_(wr6p)e6fkoyser^x3#r^zt1' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'users', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'mysite.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'mysite.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'member', + 'USER': 'root', + 'PASSWORD': 'Dkrlehowl3gudwp!', + 'HOST': '127.0.0.1', + 'PORT': '3306', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.1/topics/i18n/ + +LANGUAGE_CODE = 'ko-kr' + +TIME_ZONE = 'Asia/Seoul' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.1/howto/static-files/ + +STATIC_URL = '/static/' + +AUTH_USER_MODEL = 'users.User' + +APPEND_SLASH = False \ No newline at end of file diff --git a/mysite/mysite/urls.py b/mysite/mysite/urls.py new file mode 100644 index 0000000..17d5b29 --- /dev/null +++ b/mysite/mysite/urls.py @@ -0,0 +1,23 @@ +"""mysite URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.1/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 + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include("users.urls")), +] diff --git a/mysite/mysite/wsgi.py b/mysite/mysite/wsgi.py new file mode 100644 index 0000000..d04765f --- /dev/null +++ b/mysite/mysite/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for mysite 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/3.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') + +application = get_wsgi_application() diff --git a/mysite/users/__init__.py b/mysite/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mysite/users/admin.py b/mysite/users/admin.py new file mode 100644 index 0000000..cd61daa --- /dev/null +++ b/mysite/users/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin +from .models import Board, User, Notice, Taxi +# Register your models here. + +admin.site.register(User) +admin.site.register(Board) +admin.site.register(Notice) +admin.site.register(Taxi) \ No newline at end of file diff --git a/mysite/users/apps.py b/mysite/users/apps.py new file mode 100644 index 0000000..4ce1fab --- /dev/null +++ b/mysite/users/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + name = 'users' diff --git a/mysite/users/models.py b/mysite/users/models.py new file mode 100644 index 0000000..9a3d4e8 --- /dev/null +++ b/mysite/users/models.py @@ -0,0 +1,30 @@ +from django.db import models +from django.contrib.auth.models import AbstractUser + +# Create your models here. + +class Notice(models.Model): + author = models.CharField(max_length=10, null=False) + title = models.CharField(max_length=100, null=False) + content = models.TextField(null=False) + created_date = models.DateTimeField(auto_now_add=True) + modified_date = models.DateTimeField(auto_now=True) + +class Board(models.Model): + author = models.CharField(max_length=10, null=False) + title = models.CharField(max_length=100, null=False) + content = models.TextField(null=False) + created_date = models.DateTimeField(auto_now_add=True) + modified_date = models.DateTimeField(auto_now=True) + +class Taxi(models.Model): + author = models.CharField(max_length=10, null=False) + title = models.CharField(max_length=100, null=False) + content = models.TextField(null=False) + created_date = models.DateTimeField(auto_now_add=True) + modified_date = models.DateTimeField(auto_now=True) + + +class User(AbstractUser): + student_id = models.CharField(max_length=10) + student_cl = models.CharField(max_length=255) \ No newline at end of file diff --git a/mysite/users/templates/users/board_delivery.html b/mysite/users/templates/users/board_delivery.html new file mode 100644 index 0000000..4464694 --- /dev/null +++ b/mysite/users/templates/users/board_delivery.html @@ -0,0 +1,41 @@ + + + + + 게시판 - 글쓰기 + + +
+배달 글쓰기 +
+
+
+ {% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/mysite/users/templates/users/board_taxi.html b/mysite/users/templates/users/board_taxi.html new file mode 100644 index 0000000..3864b70 --- /dev/null +++ b/mysite/users/templates/users/board_taxi.html @@ -0,0 +1,41 @@ + + + + + 게시판 - 글쓰기 + + +
+택시 글쓰기 +
+
+
+ {% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/mysite/users/templates/users/delivery.html b/mysite/users/templates/users/delivery.html new file mode 100644 index 0000000..05874c0 --- /dev/null +++ b/mysite/users/templates/users/delivery.html @@ -0,0 +1,318 @@ + + + + + + + {% comment %} + {% endcomment %} + + Main + + + + +
+ + 배 달 + + + + + + + + + + {% for board_ds in board_d %} + + + + + + + {% endfor %} + +
번호제목글쓴이작성일
+ {{ board_ds.id }} + + + {{ board_ds.title }} + + + {{ board_ds.author }} + + {{ board_ds.created_date | date:"Y-m-d h:i" }} +
+ + + {% if user.is_authenticated %} + 글쓰기 + {% endif %} +
+ + \ No newline at end of file diff --git a/mysite/users/templates/users/index.html b/mysite/users/templates/users/index.html new file mode 100644 index 0000000..e44fabe --- /dev/null +++ b/mysite/users/templates/users/index.html @@ -0,0 +1,412 @@ + + + + + + + {% comment %} + {% endcomment %} + + Main + + + + + +
+ + 공지사항 + + + + + + + + + + {% for notice_ds in notice %} + + + + + + + {% endfor %} + + +
번호제목글쓴이작성일
+ {{ notice_ds.id }} + + + {{ notice_ds.title }} + + + {{ notice_ds.author }} + + {{ notice_ds.created_date | date:"Y-m-d h:i" }} +
+
+
+ + 배 달 + + + + + + + + + + {% for board_ds in board_d %} + + + + + + + {% endfor %} + +
번호제목글쓴이작성일
+ {{ board_ds.id }} + + + {{ board_ds.title }} + + + {{ board_ds.author }} + + {{ board_ds.created_date | date:"Y-m-d h:i" }} +
+ + +
+ {% comment %} + + + + {% for board_ds in board_d %} + + + {{ board_ds.id }} + + + + {{ board_ds.title }} + + + + {{ board_ds.author }} + + + {{ board_ds.created_date | date:"Y-m-d h:i" }} + + + {% endfor %} + + + + + {% endcomment %} +
+ + 택 시 + + + + + + + + + + {% for taxi_ds in taxi %} + + + + + + + {% endfor %} + +
번호제목글쓴이작성일
+ {{ taxi_ds.id }} + + + {{ taxi_ds.title }} + + + {{ taxi_ds.author }} + + {{ taxi_ds.created_date | date:"Y-m-d h:i" }} +
+ + +
+ + \ No newline at end of file diff --git a/mysite/users/templates/users/login.html b/mysite/users/templates/users/login.html new file mode 100644 index 0000000..0252d9e --- /dev/null +++ b/mysite/users/templates/users/login.html @@ -0,0 +1,20 @@ +로그인 페이지
+ +{% if user.is_authenticated %} +로그인성공! +{{ user.username }}님 환영합니다. +마이페이지 +로그아웃 +{% else %} + +
+{% csrf_token %} +아이디 +
+비밀번호 + + +
+회원가입 + +{% endif %} \ No newline at end of file diff --git a/mysite/users/templates/users/mypage.html b/mysite/users/templates/users/mypage.html new file mode 100644 index 0000000..801d66e --- /dev/null +++ b/mysite/users/templates/users/mypage.html @@ -0,0 +1,292 @@ + + + + + + + {% comment %} + {% endcomment %} + + Main + + + + + +

마이페이지 입니다

+ + + +{% comment %} + + My Page + + +

마이페이지 페이지입니다

+

home

+ + {% endcomment %} \ No newline at end of file diff --git a/mysite/users/templates/users/notice.html b/mysite/users/templates/users/notice.html new file mode 100644 index 0000000..93dce46 --- /dev/null +++ b/mysite/users/templates/users/notice.html @@ -0,0 +1,311 @@ + + + + + + + {% comment %} + {% endcomment %} + + Main + + + + +
+ + 공지사항 + + + + + + + + + + {% for notice_ds in notice %} + + + + + + + {% endfor %} + + + \ No newline at end of file diff --git a/mysite/users/templates/users/signup.html b/mysite/users/templates/users/signup.html new file mode 100644 index 0000000..244afad --- /dev/null +++ b/mysite/users/templates/users/signup.html @@ -0,0 +1,21 @@ +회원가입 페이지 +
+ + +{% csrf_token %} +

아이디

+ +

비밀번호

+ +

+ +

이름

+ +

이메일

+ +

학번

+ +

학과

+ + + \ No newline at end of file diff --git a/mysite/users/templates/users/taxi.html b/mysite/users/templates/users/taxi.html new file mode 100644 index 0000000..fc91a3b --- /dev/null +++ b/mysite/users/templates/users/taxi.html @@ -0,0 +1,320 @@ + + + + + + + {% comment %} + {% endcomment %} + + Main + + + + +
+
번호제목글쓴이작성일
+ {{ notice_ds.id }} + + + {{ notice_ds.title }} + + + {{ notice_ds.author }} + + {{ notice_ds.created_date | date:"Y-m-d h:i" }} +
+ 택 시 + + + + + + + + + + {% for taxi_ds in taxi %} + + + + + + + {% endfor %} + +
번호제목글쓴이작성일
+ {{ taxi_ds.id }} + + + {{ taxi_ds.title }} + + + {{ taxi_ds.author }} + + {{ taxi_ds.created_date | date:"Y-m-d h:i" }} +
+ + + + + {% if user.is_authenticated %} + 글쓰기 + {% endif %} +
+ + \ No newline at end of file diff --git a/mysite/users/tests.py b/mysite/users/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/mysite/users/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/mysite/users/urls.py b/mysite/users/urls.py new file mode 100644 index 0000000..8ab1e03 --- /dev/null +++ b/mysite/users/urls.py @@ -0,0 +1,17 @@ +from django.urls import path +from . import views + +app_name = "user" + +urlpatterns = [ + path("logout", views.logout_view, name='logout'), + path("signup", views.signup_view, name='signup'), + path('login', views.login_view, name='login'), + path("", views.index, name='index'), + path('taxi', views.taxi_view, name='taxi'), + path('delivery', views.delivery_view, name='delivery'), + path('notice', views.notice_view, name='notice'), + path('mypage', views.mypage_view, name='mypage'), + path('board_delivery', views.board_delivery), + path('board_taxi', views.board_taxi), +] \ No newline at end of file diff --git a/mysite/users/views.py b/mysite/users/views.py new file mode 100644 index 0000000..6e7eb33 --- /dev/null +++ b/mysite/users/views.py @@ -0,0 +1,98 @@ +from django.contrib.auth import authenticate, login, logout +from django.shortcuts import redirect, render +from django.urls.conf import include +from .models import * +from django.http.response import HttpResponseRedirect +from django.urls import reverse + +# Create your views here. + +def index(request): + board = {'board_d': Board.objects.all(), 'notice': Notice.objects.all(), 'taxi': Taxi.objects.all()} + return render(request, 'users/index.html', board) + +def mypage_view(request): + return render(request, 'users/mypage.html') + +def taxi_view(request): + board = {'taxi': Taxi.objects.all()} + return render(request, 'users/taxi.html', board) + +def delivery_view(request): + board = {'board_d': Board.objects.all()} + return render(request, 'users/delivery.html', board) + +def notice_view(request): + board = {'notice': Notice.objects.all()} + return render(request, 'users/notice.html', board) + +def login_view(request): + if request.method == "POST": + username = request.POST["username"] + password = request.POST["password"] + user = authenticate(username=username, password=password) + if user is not None: + print("인증성공") + login(request, user) + return redirect("user:index") + else: + print("인증실패") + + return render(request, "users/login.html") + + + +def logout_view(request): + logout(request) + return redirect("user:index") + + +def signup_view(request): + + if request.method == "POST": + print(request.POST) + username = request.POST["username"] + password = request.POST["password"] + firstname = request.POST["firstname"] + lastname = request.POST["lastname"] + email = request.POST["email"] + student_id = request.POST["student_id"] + student_cl = request.POST["student_cl"] + + user = User.objects.create_user(username, email, password) + user.last_name = lastname + user.first_name = firstname + user.student_id = student_id + user.student_cl = student_cl + user.save() + + + return redirect("user:login") + + return render(request, "users/signup.html") + +# 배달게시판 +def board_delivery(request): + + if request.method == "POST": + author = request.POST['author'] + title = request.POST['title'] + content = request.POST['content'] + board = Board(author=author, title=title, content=content) + board.save() + return redirect("user:index") + else: + return render(request, 'users/board_delivery.html') + +# 택시게시판 +def board_taxi(request): + + if request.method == "POST": + author = request.POST['author'] + title = request.POST['title'] + content = request.POST['content'] + board = Taxi(author=author, title=title, content=content) + board.save() + return redirect("user:index") + else: + return render(request, 'users/board_taxi.html')