-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,9 @@ | |
# Application definition | ||
|
||
INSTALLED_APPS = [ | ||
'furnitures.apps.FurnituresConfig', | ||
'forums.apps.ForumsConfig', | ||
'homeservices.apps.HomeservicesConfig', | ||
'restaurants.apps.RestaurantsConfig', | ||
'houseonrent.apps.HouseonrentConfig', | ||
'home.apps.HomeConfig', | ||
|
@@ -123,4 +126,14 @@ | |
STATIC_URL = '/static/' | ||
|
||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | ||
MEDIA_URL = '/media/' | ||
MEDIA_URL = '/media/' | ||
|
||
EMAIL_USE_TLS = True | ||
|
||
EMAIL_HOST = 'smtp.gmail.com' | ||
|
||
EMAIL_HOST_USER = '[email protected]' | ||
|
||
EMAIL_HOST_PASSWORD = 'butler123' | ||
|
||
EMAIL_PORT = 587 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
from forums.models import Post,Topic | ||
|
||
admin.site.register(Post) | ||
admin.site.register(Topic) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class ForumsConfig(AppConfig): | ||
name = 'forums' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.8 on 2016-09-29 17:43 | ||
from __future__ import unicode_literals | ||
|
||
import datetime | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Topic', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.TextField(max_length=1000)), | ||
('category', models.TextField(max_length=100)), | ||
('no_of_posts', models.IntegerField()), | ||
('created_time', models.DateTimeField(blank=True, default=datetime.datetime.now)), | ||
('last_updated_time', models.DateTimeField(blank=True)), | ||
('user', models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.8 on 2016-10-05 13:30 | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('forums', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Post', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('msg', models.TextField(max_length=10000)), | ||
], | ||
), | ||
migrations.RemoveField( | ||
model_name='topic', | ||
name='last_updated_time', | ||
), | ||
migrations.AddField( | ||
model_name='post', | ||
name='topic', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forums.Topic'), | ||
), | ||
migrations.AddField( | ||
model_name='post', | ||
name='user', | ||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.4 on 2016-10-06 01:21 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('forums', '0002_auto_20161005_1330'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='topic', | ||
name='no_of_posts', | ||
field=models.IntegerField(default=0), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.4 on 2016-10-06 01:33 | ||
from __future__ import unicode_literals | ||
|
||
import datetime | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('forums', '0003_auto_20161006_0651'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='post', | ||
name='created_time', | ||
field=models.DateTimeField(blank=True, default=datetime.datetime.now), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models | ||
from datetime import datetime | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class Topic(models.Model): | ||
user = models.ForeignKey(User, default=1) | ||
title = models.TextField(max_length=1000) | ||
category = models.TextField(max_length=100) | ||
no_of_posts = models.IntegerField(default=0) | ||
created_time = models.DateTimeField(default=datetime.now, blank=True) | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
|
||
class Post(models.Model): | ||
user = models.ForeignKey(User, default=1, on_delete=models.CASCADE) | ||
topic = models.ForeignKey(Topic, on_delete=models.CASCADE) | ||
msg = models.TextField(max_length=10000) | ||
created_time = models.DateTimeField(default=datetime.now, blank=True) | ||
|
||
def __str__(self): | ||
return self.topic + '-' + self.user.username |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.conf.urls import url, include | ||
from . import views | ||
|
||
app_name = 'forums' | ||
|
||
|
||
urlpatterns = [ | ||
|
||
# /forums/ | ||
url(r'^$', views.index, name='index'), | ||
|
||
# /forums/add_topic/ | ||
url(r'^add_topic/$', views.add_topic, name='add_topic'), | ||
|
||
# /forums/add_topic/ | ||
url(r'^add_topic/$', views.add_topic, name='add_topic'), | ||
|
||
# /forums/add_post/ | ||
url(r'^(?P<pk>[0-9]+)/add_topic/$', views.add_post, name='add_post'), | ||
|
||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from django.shortcuts import render, get_object_or_404 | ||
from .models import Post, Topic | ||
|
||
|
||
# Create your views here. | ||
|
||
def index(request): | ||
topics = Topic.objects.all() | ||
if request.user.is_authenticated(): | ||
base = "home/base_logged_in.html" | ||
else: | ||
base = "home/base_visitor.html" | ||
context = {'base_template': base, | ||
'topics': topics} | ||
return render(request, 'forums/forum.html', context) | ||
|
||
|
||
def add_topic(request): | ||
topic = request.POST['topic'] | ||
category = request.POST['category'] | ||
a = Topic() | ||
a.title = topic | ||
a.category = category | ||
a.user = request.user | ||
a.save() | ||
return index(request) | ||
|
||
|
||
def add_post(request, pk): | ||
post = request.POST['post'] | ||
topic = get_object_or_404(Topic, pk=pk) | ||
a = Post() | ||
a.user = request.user | ||
a.topic = topic | ||
a.msg = post | ||
a.save() | ||
topic.no_of_posts += 1 | ||
topic.save() | ||
return index(request) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib import admin | ||
from .models import Furniture, Picture, BookmarkFurniture | ||
|
||
admin.site.register(Furniture) | ||
admin.site.register(Picture) | ||
admin.site.register(BookmarkFurniture) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class FurnituresConfig(AppConfig): | ||
name = 'furnitures' |