Skip to content

Commit 571ddd8

Browse files
Adding initial files
1 parent da5951a commit 571ddd8

31 files changed

+523
-0
lines changed

db.sqlite3

168 KB
Binary file not shown.

manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myFirstDjangoProject.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

myFirstDjangoProject/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

myFirstDjangoProject/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for myFirstDjangoProject project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myFirstDjangoProject.settings')
15+
16+
application = get_asgi_application()

myFirstDjangoProject/settings.py

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
"""
2+
Django settings for myFirstDjangoProject project.
3+
4+
Generated by 'django-admin startproject' using Django 4.0.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.0/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
import os
15+
16+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
17+
BASE_DIR = Path(__file__).resolve().parent.parent
18+
19+
20+
# Quick-start development settings - unsuitable for production
21+
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
22+
23+
# SECURITY WARNING: keep the secret key used in production secret!
24+
SECRET_KEY = 'django-insecure-nx=a-t0d%tf4*mrws4hq_o1=9e&ko$#pntt3)6bva=lfim7vm5'
25+
26+
# SECURITY WARNING: don't run with debug turned on in production!
27+
DEBUG = True
28+
29+
ALLOWED_HOSTS = []
30+
31+
32+
# Application definition
33+
34+
INSTALLED_APPS = [
35+
'django.contrib.admin',
36+
'django.contrib.auth',
37+
'django.contrib.contenttypes',
38+
'django.contrib.sessions',
39+
'django.contrib.messages',
40+
'django.contrib.staticfiles',
41+
42+
'webchat',
43+
]
44+
45+
MIDDLEWARE = [
46+
'django.middleware.security.SecurityMiddleware',
47+
'django.contrib.sessions.middleware.SessionMiddleware',
48+
'django.middleware.common.CommonMiddleware',
49+
'django.middleware.csrf.CsrfViewMiddleware',
50+
'django.contrib.auth.middleware.AuthenticationMiddleware',
51+
'django.contrib.messages.middleware.MessageMiddleware',
52+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
53+
]
54+
55+
ROOT_URLCONF = 'myFirstDjangoProject.urls'
56+
57+
TEMPLATES = [
58+
{
59+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
60+
'DIRS': [
61+
os.path.join(BASE_DIR, 'templates')
62+
],
63+
'APP_DIRS': True,
64+
'OPTIONS': {
65+
'context_processors': [
66+
'django.template.context_processors.debug',
67+
'django.template.context_processors.request',
68+
'django.contrib.auth.context_processors.auth',
69+
'django.contrib.messages.context_processors.messages',
70+
],
71+
},
72+
},
73+
]
74+
75+
WSGI_APPLICATION = 'myFirstDjangoProject.wsgi.application'
76+
77+
78+
# Database
79+
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
80+
81+
DATABASES = {
82+
'default': {
83+
'ENGINE': 'django.db.backends.sqlite3',
84+
'NAME': BASE_DIR / 'db.sqlite3',
85+
}
86+
}
87+
88+
89+
# Password validation
90+
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
91+
92+
AUTH_PASSWORD_VALIDATORS = [
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
98+
},
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
101+
},
102+
{
103+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
104+
},
105+
]
106+
107+
108+
# Internationalization
109+
# https://docs.djangoproject.com/en/4.0/topics/i18n/
110+
111+
LANGUAGE_CODE = 'en-us'
112+
113+
TIME_ZONE = 'UTC'
114+
115+
USE_I18N = True
116+
117+
USE_TZ = True
118+
119+
120+
# Static files (CSS, JavaScript, Images)
121+
# https://docs.djangoproject.com/en/4.0/howto/static-files/
122+
123+
STATIC_URL = 'static/'
124+
125+
STATICFILES_DIRS = [
126+
os.path.join(BASE_DIR,'static'),
127+
]
128+
129+
# Default primary key field type
130+
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
131+
132+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

myFirstDjangoProject/urls.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""myFirstDjangoProject URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/4.0/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
17+
from django.contrib import admin
18+
from django.urls import path, re_path
19+
from webchat import views
20+
21+
#https://docs.djangoproject.com/en/4.0/topics/http/urls/
22+
urlpatterns = [
23+
24+
#path('homepage/', views.homepage, name='homepage'),
25+
path('', views.home, name='home'),#default home page path
26+
path('home/', views.home, name='home'),
27+
28+
#path('board_topic/', views.board_topic, name='board_topic'),
29+
re_path(r'^board_topic/(?P<pk>\d+)/$', views.board_topic, name='board_topic'),
30+
re_path(r'^board_topic/(?P<pk>\d+)/new/$', views.new_board_topic, name='new_board_topic'),
31+
32+
# =============================================================================
33+
# path('about/', views.about, name='about'),
34+
# path('about/comapny', views.about_company, name='about_comapny'),
35+
# path('about/author', views.about_author, name='about_author'),
36+
# path('about/privacy', views.about_privacy, name='about_privacy'),
37+
# =============================================================================
38+
39+
#path('(?P<username>[\w.@+-]+)/$', views.user_profile, name='user_profile')
40+
41+
42+
43+
path('admin/', admin.site.urls),
44+
45+
]
46+
47+
#url writing convention
48+
#def url(regex, view, kwarg=None, name=None):
49+
#http://127.0.0.1:8000/chatboard/?page=5 only/chat_topic

myFirstDjangoProject/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for myFirstDjangoProject project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myFirstDjangoProject.settings')
15+
16+
application = get_wsgi_application()

static/css/bootstrap.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/base.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% load static %}
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<meta charset="utf-8">
6+
<title>{% block title %}Web Chat Boards{% endblock %}</title>
7+
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
8+
</head>
9+
<body>
10+
11+
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
12+
<div class="container">
13+
<a class="navbar-brand" href="{% url 'home' %}">Web Chat Boards</a>
14+
</div>
15+
</nav>
16+
17+
<div class="container">
18+
<ol class="breadcrumb my-4">
19+
{% block breadcrumb %}
20+
{% endblock %}
21+
</ol>
22+
{% block content %}
23+
{% endblock %}
24+
</div>
25+
</body>
26+
</html>

templates/chat_board_topics.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{% extends 'base.html' %}
2+
3+
{% block title %}
4+
{{ board.name }} - {{ block.super }}
5+
{% endblock %}
6+
7+
{% block breadcrumb %}
8+
<li class="breadcrumb-item"><a href="{% url 'home' %}">Web Chat Boards</a></li>
9+
<li class="breadcrumb-item active">{{ chat_board.name }}</li>
10+
11+
{% endblock %}
12+
13+
{% block content %}
14+
<table class="table">
15+
<thead class="thead-inverse">
16+
<tr>
17+
<th>Topic</th>
18+
<th>Board Starter</th>
19+
<th>Replies</th>
20+
<th>Views</th>
21+
<th>Last Updated</th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
{% for topic in boardName.topics.all %}
26+
<tr>
27+
<td>{{ topic.subject }}</td>
28+
<td>{{ topic.boardStarter.username }}</td>
29+
<td>0</td>
30+
<td>0</td>
31+
<td>{{ topic.lastUpdate }}</td>
32+
</tr>
33+
{% endfor %}
34+
</tbody>
35+
</table>
36+
37+
{% endblock %}

templates/home.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{% extends 'base.html' %}
2+
3+
{% block breadcrumb %}
4+
<li class="breadcrumb-item active">Chat Boards</li>
5+
{% endblock %}
6+
7+
{% block content %}
8+
<table class="table">
9+
<thead class="thead-inverse">
10+
<tr>
11+
<th>Board Name</th>
12+
<th>Posts</th>
13+
<th>Topics</th>
14+
<th>Last Post</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
{% for board in chatBoard %}
19+
<tr>
20+
<td>
21+
{{ board.name }}
22+
<small class="text-muted d-block">{{ board.details }}</small>
23+
</td>
24+
<td class="align-middle">0</td>
25+
<td class="align-middle">0</td>
26+
<td>
27+
</td>
28+
</tr>
29+
{% endfor %}
30+
</tbody>
31+
</table>
32+
{% endblock %}

templates/new_board_topic.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends 'base.html' %}
2+
3+
{% block title %}
4+
Start a New Chat Topic
5+
{% endblock %}
6+
7+
{% block breadcrumb %}
8+
<li class="breadcrumb-item"><a href="{% url 'home' %}">Web Chat Boards</a></li>
9+
<li class="breadcrumb-item"><a href="{% url 'board_topic' chat_board.pk %}">{{ chat_board.name }}</a></li>
10+
<li class="breadcrumb-item active">New topic</li>
11+
{% endblock %}
12+
13+
{% block content %}
14+
15+
<form method="post">
16+
{% csrf_token %}
17+
<div class="form-group">
18+
<label for="id_subject">Subject</label>
19+
<input type="text" class="form-control" id="id_subject" name="subject">
20+
</div>
21+
<div class="form-group">
22+
<label for="id_message">Message</label>
23+
<textarea class="form-control" id="id_message" name="message" rows="5"></textarea>
24+
</div>
25+
<button type="submit" class="btn btn-success">Post</button>
26+
</form>
27+
{% endblock %}

webchat/__init__.py

Whitespace-only changes.
161 Bytes
Binary file not shown.
277 Bytes
Binary file not shown.
440 Bytes
Binary file not shown.
1.37 KB
Binary file not shown.
1.32 KB
Binary file not shown.

webchat/admin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Register your models here.
2+
3+
from django.contrib import admin
4+
from.models import ChatBoard
5+
6+
admin.site.register(ChatBoard)
7+

webchat/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class WebchatConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'webchat'

0 commit comments

Comments
 (0)