Skip to content
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 db.sqlite3
Binary file not shown.
Binary file modified finance_resources/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified finance_resources/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file modified finance_resources/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file modified finance_resources/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file modified finance_resources/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified finance_resources/__pycache__/views.cpython-310.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion finance_resources/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from .models import Resource
from .models import Resource, Post

admin.site.register(Resource)
admin.site.register(Post)
25 changes: 25 additions & 0 deletions finance_resources/migrations/0003_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.1.5 on 2023-04-30 02:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('finance_resources', '0002_alter_resource_contact_num_and_more'),
]

operations = [
migrations.CreateModel(
name='Post',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(default='anonymous', max_length=100)),
('description', models.CharField(max_length=1000)),
('date_created', models.DateTimeField(auto_now_add=True, null=True)),
],
options={
'ordering': ['date_created'],
},
),
]
18 changes: 18 additions & 0 deletions finance_resources/migrations/0004_post_likes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.5 on 2023-04-30 04:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('finance_resources', '0003_post'),
]

operations = [
migrations.AddField(
model_name='post',
name='likes',
field=models.PositiveIntegerField(default=0),
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 13 additions & 1 deletion finance_resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ class Resource(models.Model):
description = models.CharField(max_length=1300)

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

class Post(models.Model):
name=models.CharField(max_length=100,default="anonymous")
description=models.CharField(max_length=1000)
date_created=models.DateTimeField(auto_now_add=True, null=True)
likes=models.PositiveIntegerField(default=0)

class Meta:
ordering = ['date_created']

def __str__(self):
return self.name + " (" + str(self.date_created) + ")"
Binary file added finance_resources/static/profile.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion finance_resources/static/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
nav a:hover{
.nav a:hover{
background-color: #84b4a4;
color: #000000;
}

.modal {
text-align:center;
padding: 0!important;
}

.modal:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -4px;
}

.modal-dialog {
display: inline-block;
text-align: left;
vertical-align: middle;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
{% extends 'finance_resources/base.html' %}
{% load static %}

{% block title %}Discussion Form{% endblock %}

{% block content %}Discussion Forum{% endblock %}
{% block content %}
<div class="container">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newPost">Add New Post</button>
<div id="newPost" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="newPost">
{% csrf_token %}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">New Post</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name" name="name">
</div>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment" name="comment"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" name="save", value="save" class="btn btn-default">Save</button>
</div>
</form>
</div>
</div>
</div>
{% for post in posts %}
<div class="container" style="background-color: #b9d2b7; margin-top: 20px; padding: 10px; border-style: solid; border-width: 2px; border-color: gray">
<div class="col-sm-1">
<img src="{% static 'profile.jpg' %}" width="60" height="60" />
</div>
<div class="col-sm-11">
<h4>{{ post.name }}</h4>
<h4><small>{{ post.date_created|date:"m/d/Y g:iA" }}</small></h4>
<p>{{ post.description }}</p>
<span class="pull-right" style="margin-left: 5px">{{ post.likes }}</span>
<a class="pull-right" href="{% url 'likePost' post.id %}">
<span class="glyphicon glyphicon-thumbs-up"></span>
</a>
<br>
<div style="margin-top: 5px" class="form-group">
<textarea class="form-control" rows="2" id="reply" placeholder="Reply to above comment..."></textarea>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
2 changes: 2 additions & 0 deletions finance_resources/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
path('find_matches', views.find_matches, name='find_matches'),
path('all_resources', views.all_resources, name='all_resources'),
path('discussion_forum', views.discussion_forum, name='discussion_forum'),
path('newPost', views.newPost, name='newPost'),
path('likePost/<int:id>', views.likePost, name='likePost')
]
23 changes: 20 additions & 3 deletions finance_resources/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.shortcuts import render
from .models import Resource
from django.shortcuts import render, redirect
from .models import Resource, Post
from django.http import HttpResponse

def home(response):
Expand All @@ -13,4 +13,21 @@ def all_resources(response):
return render(response, "finance_resources/all_resources.html", {"resources": resources})

def discussion_forum(response):
return render(response, "finance_resources/discussion_forum.html")
posts = Post.objects.all()
return render(response, "finance_resources/discussion_forum.html", {"posts": posts})

def newPost(response):
if response.method == "POST":
if response.POST.get("name"):
person = response.POST.get('name')
if response.POST.get('comment'):
comment = response.POST.get('comment')
p = Post.objects.create(name=person, description=comment)
p.save()
return redirect(discussion_forum)

def likePost(response, id):
p = Post.objects.get(id=id)
p.likes += 1
p.save()
return redirect(discussion_forum)
Binary file modified henhacks/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified henhacks/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified henhacks/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file modified henhacks/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion henhacks/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
TIME_ZONE = 'America/New_York'

USE_I18N = True

Expand Down