diff --git a/wow_bizwiz/bizwiz/Templates/Industry.html b/wow_bizwiz/bizwiz/Templates/Industry.html index 923e154..1dd8858 100644 --- a/wow_bizwiz/bizwiz/Templates/Industry.html +++ b/wow_bizwiz/bizwiz/Templates/Industry.html @@ -26,7 +26,7 @@

{{question.question_text}}
-

author: {{question.user}} dateposted: {{question.dateposted}}

+

author: {{question.user}} dateposted: {{question.dateposted}}{{question.timezone}}

({{question.answer_set.count}})answers

diff --git a/wow_bizwiz/bizwiz/Templates/Specific_Question.html b/wow_bizwiz/bizwiz/Templates/Specific_Question.html index 4c0a641..827675a 100644 --- a/wow_bizwiz/bizwiz/Templates/Specific_Question.html +++ b/wow_bizwiz/bizwiz/Templates/Specific_Question.html @@ -20,7 +20,7 @@

{{question.id}}. {{question.question_text}}

{% for answer in answers %}
  • {{answer.answer_text}} -

    author:{{answer.user}} posted:{{answer.dateposted}} likes: {{answer.likes.count}}

  • +

    author:{{answer.user}} posted:{{answer.dateposted}}{{answer.timezone}} likes: {{answer.likes.count}}

    {% endfor %} {% else %} diff --git a/wow_bizwiz/bizwiz/Templates/User_Profile.html b/wow_bizwiz/bizwiz/Templates/User_Profile.html index 1f44944..d277b19 100644 --- a/wow_bizwiz/bizwiz/Templates/User_Profile.html +++ b/wow_bizwiz/bizwiz/Templates/User_Profile.html @@ -1,66 +1,69 @@ - - - {% load static %} - - -Home - - -BizWiz - -
    - Hello, {{request.user}} - Log Out -
    - - -

    Hi, {{request.user.first_name}}

    + + + + {% load static %} + + + Home + + + BizWiz + +
    + Hello, {{request.user}} + Log Out +
    + + +

    Hi, {{request.user.first_name}}

    -

    Answers contributed

    -
      -{% for answers in answer %} -
    1. {{answers.answer_text}}
    2. -{% endfor %} -
    -

    Questions contributed

    -
      -{% for questions in question %} -
    1. {{questions.question_text}}
    2. -
    -{% endfor %} -

    Liked Post

    -
      -{% for likes in liked %} -{{likes.answer_id}} -{% endfor %} -
    +
    +
    +

    Answers contributed

    + {% for answers in answer %} +

    {{answers.answer_text}}{{answers.timezone}}

    + {% endfor %} +
    +
    +

    Questions contributed

    + {% for questions in question %} +

    {{questions.question_text}}

    + {% endfor %} +
    +
    +

    Liked Post

    + {% for likes in liked_post %} +

    {{likes}}

    + {% endfor %} +
    +
    - + - + \ No newline at end of file diff --git a/wow_bizwiz/bizwiz/Templates/faq.html b/wow_bizwiz/bizwiz/Templates/faq.html new file mode 100644 index 0000000..8ad619f --- /dev/null +++ b/wow_bizwiz/bizwiz/Templates/faq.html @@ -0,0 +1,35 @@ + + + {% load static %} + +
    +
    + BizWiz +
    +
    + Hello, {{request.user}} + Log Out +

    Frequently Asked Questions

    +
    + + + +
    +
      +
    1. Can I post the same question on for multiple industries ?

    2. +

      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.

      +
    3. How can I change my username/password ?

    4. +

      You can change your username/password on the profile page under profile settings.

      +
    5. Can I edit my answers / questions ?

    6. +

      You can edit your answer using the update button to edit your post.

      +
    7. How can I report bugs on the site ?

    8. +

      contact the developers through email at coders4life111@gmail.com

      +
    9. Where can I find the Biz Wiz social media pages ?

    10. +

      The footer of the home page has all Biz Wiz instagram, twitter, and facebook page link

      +
    +
    + + + + + \ No newline at end of file diff --git a/wow_bizwiz/bizwiz/Templates/home.html b/wow_bizwiz/bizwiz/Templates/home.html index a8636f5..e7ae5a4 100644 --- a/wow_bizwiz/bizwiz/Templates/home.html +++ b/wow_bizwiz/bizwiz/Templates/home.html @@ -36,6 +36,7 @@

    Top Industries

    {{tag.tag_name}} {% endfor %}
    + FAQ
    diff --git a/wow_bizwiz/bizwiz/models.py b/wow_bizwiz/bizwiz/models.py index a72163d..4ad50a3 100644 --- a/wow_bizwiz/bizwiz/models.py +++ b/wow_bizwiz/bizwiz/models.py @@ -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. @@ -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 @@ -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') diff --git a/wow_bizwiz/bizwiz/urls.py b/wow_bizwiz/bizwiz/urls.py index df20d22..3d97061 100644 --- a/wow_bizwiz/bizwiz/urls.py +++ b/wow_bizwiz/bizwiz/urls.py @@ -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'), diff --git a/wow_bizwiz/bizwiz/views.py b/wow_bizwiz/bizwiz/views.py index fbe4a3c..db6df05 100644 --- a/wow_bizwiz/bizwiz/views.py +++ b/wow_bizwiz/bizwiz/views.py @@ -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 @@ -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) @@ -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 @@ -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''' @@ -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 @@ -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''' @@ -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} + ) \ No newline at end of file diff --git a/wow_bizwiz/wow_bizwiz/settings.py b/wow_bizwiz/wow_bizwiz/settings.py index 17fa5c9..f4cf746 100644 --- a/wow_bizwiz/wow_bizwiz/settings.py +++ b/wow_bizwiz/wow_bizwiz/settings.py @@ -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'),] @@ -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 @@ -107,7 +108,7 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'EST' USE_I18N = True