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
2 changes: 1 addition & 1 deletion wow_bizwiz/bizwiz/Templates/Industry.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h3>
<div class="buttontext3 overflowfix">
<a href="{% url 'specific_question' industry.id question.id %}">{{question.question_text}}</a>
</div>
<p class="dateposted" style="margin:0%; "> author: {{question.user}} dateposted: {{question.dateposted}} </p></h3>
<p class="dateposted" style="margin:0%; "> author: {{question.user}} dateposted: {{question.dateposted}}{{question.timezone}} </p></h3>
<h6 class= 'form' style="margin:0%; white-space: break-spaces; ">({{question.answer_set.count}})answers</h6>
<p
class= 'preview buttontext3' style="margin:0%; ">
Expand Down
2 changes: 1 addition & 1 deletion wow_bizwiz/bizwiz/Templates/Specific_Question.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class= "form" > {{question.id}}. {{question.question_text}}</h1>
{% for answer in answers %}
<div class="griditem1 button3 ">
<li class="buttontext3" > <a href="{% url 'updating_page' industry.id question.id answer.id %}">{{answer.answer_text}} </a>
<p class="dateposted preview ">author:{{answer.user}} posted:{{answer.dateposted}} likes: {{answer.likes.count}}</p></li>
<p class="dateposted preview ">author:{{answer.user}} posted:{{answer.dateposted}}{{answer.timezone}} likes: {{answer.likes.count}}</p></li>
</div>
{% endfor %}
{% else %}
Expand Down
119 changes: 61 additions & 58 deletions wow_bizwiz/bizwiz/Templates/User_Profile.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,69 @@
<html>
<head class = 'front' style="transform: translate(0mm,6mm);">
{% load static %}
<link rel= "stylesheet" href="{% static 'style.css' %}" >
<a class="fix form" style="margin:1mm; margin-top:10px;" href="{% url 'home' %}">
<img src="{% static 'Home.png' %}" height="50" width="50" alt="Home" />
</a>
<a>
<img src="{% static 'WizTransparent.png' %}" height="140" width="135" alt="BizWiz" />
</a>
<div class='front'; style="text-align:right; transform: translate(0mm,-30mm); white-space: pre-line; position:sticky;">
<span> Hello, {{request.user}} </span>
<span> <a href="{% url 'signout'%}"> Log Out </a> </span>
</div>
</head>
<body>
<h1 class= form> Hi, {{request.user.first_name}} </h1>
<!DOCTYPE html>
<html lang="en">
<head class = 'front' style="transform: translate(0mm,6mm);">
{% load static %}
<link rel= "stylesheet" href="{% static 'style.css' %}" >
<a class="fix form" style="margin:1mm; margin-top:10px;" href="{% url 'home' %}">
<img src="{% static 'Home.png' %}" height="50" width="50" alt="Home" />
</a>
<a>
<img src="{% static 'WizTransparent.png' %}" height="140" width="135" alt="BizWiz" />
</a>
<div class='front'; style="text-align:right; transform: translate(0mm,-30mm); white-space: pre-line; position:sticky;">
<span> Hello, {{request.user}} </span>
<span> <a href="{% url 'signout'%}"> Log Out </a> </span>
</div>
</head>
<body>
<h1 class= form> Hi, {{request.user.first_name}} </h1>

<h3>Answers contributed</h3>
<ol>
{% for answers in answer %}
<li>{{answers.answer_text}}</li>
{% endfor %}
</ol>
<h3>Questions contributed</h3>
<ol>
{% for questions in question %}
<li>{{questions.question_text}}</li>
</ol>
{% endfor %}
<h3>Liked Post</h3>
<ol>
{% for likes in liked %}
{{likes.answer_id}}
{% endfor %}
</ol>
<div class = "profilegrid">
<div class="answersitem">
<h3>Answers contributed</h3>
{% for answers in answer %}
<p class = 'button2 buttonact'> {{answers.answer_text}}{{answers.timezone}} </p>
{% endfor %}
</div>
<div class = "questionsitem">
<h3>Questions contributed</h3>
{% for questions in question %}
<p class = 'button2 buttonact'>{{questions.question_text}}</p>
{% endfor %}
</div>
<div class="likeditem">
<h3>Liked Post</h3>
{% for likes in liked_post %}
<p class = 'button2 buttonact' >{{likes}}</p>
{% endfor %}
</div>
</div>



</body>
</body>


<footer>
<hr>
<div class="form">
<div class= "row" style="transform: translate(0mm,-4mm);">
<div class="rotate" style="transform: translate(1rem,-.4mm); margin-top: 0mm; margin-bottom: 0mm;">
<a href ="https://twitter.com/BizWiz000 ">
<img src ="{% static 'Twitter Logo.png' %}" height ="52" width ="54" alt ="Twitter" >
</a>
</div>
<div class="rotate" style="transform: translate(0rem,1.5mm);">
<a href ="https://www.instagram.com/bizwiz111/">
<img src ="{% static 'Instagram Logo.png' %}" height ="37" width ="39" alt ="Instagram" >
</a>
</div>
<div class="rotate" style="transform: translate(-1rem,-1mm);">
<a href ="https://www.facebook.com/profile.php?id=100081355037787 ">
<img src ="{% static 'Facebook Logo.png' %}" height ="56" width ="55" alt ="Facebook" >
</a>
</div>
</div>
<footer>
<hr>
<div class="form">
<div class= "row" style="transform: translate(0mm,-4mm);">
<div class="rotate" style="transform: translate(1rem,-.4mm); margin-top: 0mm; margin-bottom: 0mm;">
<a href ="https://twitter.com/BizWiz000 ">
<img src ="{% static 'Twitter Logo.png' %}" height ="52" width ="54" alt ="Twitter" >
</a>
</div>
<div class="rotate" style="transform: translate(0rem,1.5mm);">
<a href ="https://www.instagram.com/bizwiz111/">
<img src ="{% static 'Instagram Logo.png' %}" height ="37" width ="39" alt ="Instagram" >
</a>
</div>
<div class="rotate" style="transform: translate(-1rem,-1mm);">
<a href ="https://www.facebook.com/profile.php?id=100081355037787 ">
<img src ="{% static 'Facebook Logo.png' %}" height ="56" width ="55" alt ="Facebook" >
</a>
</div>
</footer>

</div>
</div>
</footer>

</html>
35 changes: 35 additions & 0 deletions wow_bizwiz/bizwiz/Templates/faq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<head>
{% load static %}
<link rel = "stylesheet" href ="{% static 'style.css' %}" >
<div class="form" style="margin-top: -8mm;">
<div class ="rotate">
<img src ="{% static 'WizTransparent.png' %}" height ="175" width ="185" alt ="BizWiz" >
</div>
<div style="text-align:right; transform: translate(0mm,-15mm); white-space: pre-line;">
<span> Hello,<a href="{% url 'profile_page' user_id.id %}"> {{request.user}} </a> </span>
<span> <a href="{% url 'signout'%}"> Log Out </a> </span>
<h1 class="title">Frequently Asked Questions</h1>
</div>
</head>

<body>
<div class="form" style="background-color: purple; color: white;">
<ol>
<li> <h3> Can I post the same question on for multiple industries ? </h3> </li>
<p>You can only post for one industry at a time. However you're able to post the same question in different industry post if it applies.</p>
<li> <h3> How can I change my username/password ? </h3> </li>
<p>You can change your username/password on the profile page under profile settings.</p>
<li> <h3> Can I edit my answers / questions ? </h3> </li>
<p> You can edit your answer using the update button to edit your post.</p>
<li> <h3> How can I report bugs on the site ? </h3> </li>
<p> contact the developers through email at coders4life111@gmail.com </p>
<li> <h3> Where can I find the Biz Wiz social media pages ?</h3> </li>
<p>The footer of the home page has all Biz Wiz instagram, twitter, and facebook page link </p>
</ol>
</div>

</body>


</html>
1 change: 1 addition & 0 deletions wow_bizwiz/bizwiz/Templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h1 class="title">Top Industries</h1>
<a href ="{% url 'page_for_tags' tag.id %}">{{tag.tag_name}}</a>
{% endfor %}
</div>
<a href="{% url 'faq' %}">FAQ</a>
<hr>
<div class="form">
<div class= "row" style="transform: translate(0mm,-4mm);">
Expand Down
6 changes: 4 additions & 2 deletions wow_bizwiz/bizwiz/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.utils.timezone import datetime
from datetime import timezone

from django.utils import timezone
from pyexpat import model
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
import pytz

# Create your models here.

Expand All @@ -26,6 +26,7 @@ class Question(models.Model):
#Attribute in tbe model to connect the question text to a industry
industry= models.ForeignKey( Industry,on_delete=models.CASCADE)#If industry is deleted all questions are deleted
dateposted = models.DateTimeField( auto_now= False, auto_now_add= True )#Time Posted
timezone= timezone.now().tzname #Timezone name
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) #User as foreign key
class Answer(models.Model):
# An ID field is automatically added to all Django models
Expand All @@ -34,6 +35,7 @@ class Answer(models.Model):
#Attribute in tbe model to connect the answer to a question
question= models.ForeignKey(Question,on_delete=models.CASCADE)#If question is deleted answers are deleted
dateposted = models.DateTimeField( auto_now= False, auto_now_add= True )#Time Posted
timezone= timezone.now().tzname #Timezone Name
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) #User as foreign key
likes = models.ManyToManyField(User, related_name='blog_post')

Expand Down
1 change: 1 addition & 0 deletions wow_bizwiz/bizwiz/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
urlpatterns = [
path('', views.registerPage, name='register'),
path('home/', HomeView.as_view(), name='home'),
path('home/faq/', FAQview.as_view(), name='faq'),
path('industries/', IndustriesView.as_view(), name='industries'),
path('signin/', views.signin, name='signin'),
path('signout/', views.signout, name='signout'),
Expand Down
52 changes: 43 additions & 9 deletions wow_bizwiz/bizwiz/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from asyncio.windows_events import NULL
from functools import cache
from genericpath import exists
import imp
from importlib.util import cache_from_source
from multiprocessing import context
from tkinter.messagebox import QUESTION

from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.http import HttpResponseRedirect
from django.http import HttpResponseRedirect, HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse, reverse_lazy
from django.utils.decorators import method_decorator
Expand All @@ -27,10 +31,11 @@ def LikeView(request,industry_id,question_id,answer_id):
else:
post.likes.add(request.user)
liked= True

user_id= User.objects.get(id= request.user.id)
answer = Answer.objects.get(id=answer_id)
industry = Industry.objects.get(id=industry_id)
question = Question.objects.get(id=question_id)
context={"user_id":user_id, "answer":answer,"industry":industry,"question":question}
return redirect('updating_page', industry_id=industry_id,question_id=question_id, answer_id = answer_id)


Expand Down Expand Up @@ -91,15 +96,17 @@ def get(self, request):
industries= Industry.objects.all()
top_industries = Industry.objects.filter(id__lte = 9)
tag=Tag.objects.all()
user_id= User.objects.get(id= request.user.id)
return render(
request=request, template_name = 'home.html', context = {"industries":industries,"tag":tag, "top_industries":top_industries}
request=request, template_name = 'home.html', context = {"industries":industries,"tag":tag, "top_industries":top_industries,"user_id":user_id}
)
@method_decorator(login_required(login_url='signin'), name='dispatch')
class IndustriesView(View):
def get(self, request):
industries= Industry.objects.all()
user_id= User.objects.get(id= request.user.id)
return render(
request=request, template_name = 'industries.html', context = {"industries":industries}
request=request, template_name = 'industries.html', context = {"industries":industries,"uder_id":user_id}
)

# Industry views should display industry with its questions and take in a form to add questions
Expand All @@ -110,9 +117,17 @@ def get(self, request, industry_id):
question= Question.objects.all()
questions= Question.objects.filter(industry_id = industry_id)
form = QuestionForm(initial={'question_text': Question.question_text})
user_id= User.objects.get(id= request.user.id)
if Question.timezone == 'UTC':
timezone = Question.timezone
dateposted = Question.dateposted
elif Question.timezone == 'EST':
timezone = 'EST'
Question.dateposted


return render(
request=request, template_name= 'Industry.html', context={'industry':industry,'form':form,'question':question,'questions':questions}
request=request, template_name= 'Industry.html', context={'industry':industry,'form':form,'question':question,'questions':questions,"user_id":user_id,"timezone":timezone,"dateposted":dateposted}
)
def post(self, request, industry_id):
'''post questions based on what the user submitted in the form'''
Expand Down Expand Up @@ -158,8 +173,9 @@ class Page_for_TagsView(View):
def get(self, request,tag_id):
tags=Tag.objects.get(id=tag_id)
industry= Industry.objects.filter(tags=tag_id)
user_id= User.objects.get(id= request.user.id)
return render(
request=request, template_name= 'page_for_tags.html', context={"tags":tags,"industry":industry}
request=request, template_name= 'page_for_tags.html', context={"tags":tags,"industry":industry,"user_id":user_id}
)

# Updating_Page views should taken in a form to update answers to specific questions
Expand All @@ -170,13 +186,14 @@ def get(self, request,industry_id,question_id,answer_id):
industry = Industry.objects.get(id=industry_id)
question = Question.objects.get(id=question_id)
form = Updating_PageForm(initial={'update': answer.answer_text})
user_id= User.objects.get(id= request.user.id)
post = get_object_or_404(Answer, id=answer_id)
total_likes=post.total_likes()
liked = False
if post.likes.filter(id = self.request.user.id).exists():
liked = True
return render(
request=request, template_name = 'Updating_Page.html', context = {"form":form,"answer":answer,"industry":industry,"question":question,"total_likes":total_likes, "liked":liked,}
request=request, template_name = 'Updating_Page.html', context = {"form":form,"answer":answer,"industry":industry,"question":question,"total_likes":total_likes, "liked":liked,"user_id":user_id}
)
def post(self, request, answer_id,industry_id,question_id):
'''Update or delete the specific answers based on what the user submitted in the form'''
Expand All @@ -197,7 +214,24 @@ def get(self, request,user_id):
user_id= User.objects.get(id= request.user.id)
question = Question.objects.filter(user_id = user_id)
answer = Answer.objects.filter(user_id = user_id)
liked = User.objects.filter(blog_post__user_id = user_id)
answers = Answer.objects.all()
liked_post = []
# Loop through all post to find liked post and add liked post to users liked post list
for i in range(len(answers)):
post = get_object_or_404(Answer, id=answers[i].id)
liked = False
if post.likes.filter(id = self.request.user.id).exists():
liked = True
liked_post.append(post.answer_text)

return render(
request=request, template_name = 'User_Profile.html', context = {"user_id":user_id,"question":question,"answer":answer,"liked":liked}
request=request, template_name = 'User_Profile.html', context = {"user_id":user_id,"question":question,"answer":answer,"liked":liked,"answers":answers,'liked_post':liked_post}
)

class FAQview(View):
def get(self, request):
user_id= User.objects.get(id= request.user.id)

return render(
request=request, template_name = 'faq.html', context = {"user_id":user_id}
)
5 changes: 3 additions & 2 deletions wow_bizwiz/wow_bizwiz/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
from pathlib import Path


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
STATICFILES_DIRS= [os.path.join(BASE_DIR,'static'),]
Expand All @@ -26,7 +27,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['e73e-2603-7000-5f00-938a-fc92-3d41-1fe-4989.ngrok.io','127.0.0.1']


# Application definition
Expand Down Expand Up @@ -107,7 +108,7 @@

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
TIME_ZONE = 'EST'

USE_I18N = True

Expand Down