Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hangouts/meeting feature #46

Draft
wants to merge 22 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions project/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
INSTALLED_APPS = [
'accounts',
'chapters',
'hangouts',
'home',
'invites',
'search',
Expand Down
Empty file added project/hangouts/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions project/hangouts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions project/hangouts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class HangoutsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'hangouts'
43 changes: 43 additions & 0 deletions project/hangouts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 3.2.6 on 2021-12-07 08:11

from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import wagtail.core.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0062_comment_models_and_pagesubscription'),
('taggit', '0003_taggeditem_add_unique_index'),
]

operations = [
migrations.CreateModel(
name='HangoutsIndexPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('introduction', wagtail.core.fields.RichTextField()),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='Hangout',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('description', wagtail.core.fields.RichTextField()),
('hangouts_link', models.URLField(blank=True)),
('topics', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file.
49 changes: 49 additions & 0 deletions project/hangouts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from django.db import models
from taggit.managers import TaggableManager
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page
from wagtail.core.blocks import URLBlock


# Create your models here.
class Hangout(Page):
description = RichTextField()
topics = TaggableManager()
Upasanadhameliya marked this conversation as resolved.
Show resolved Hide resolved
hangouts_link = models.URLField(blank=True)

content_panels = Page.content_panels + [
FieldPanel("description",classname="full"),
FieldPanel("topics",classname="full"),
FieldPanel("hangouts_link",classname="full")
]
parent_page_types = [
"hangouts.HangoutsIndexPage",
]
subpage_types = []


class HangoutsIndexPage(Page):
introduction = RichTextField()

content_panels = Page.content_panels + [
FieldPanel("introduction"),
]

parent_page_types = [
"home.HomePage",
]

subpage_types = ["hangouts.Hangout"]

max_count = 1

def get_context(self, request, *args, **kwargs):
context = super().get_context(request, *args, **kwargs)
context["hangouts"] = (
self.allowed_subpage_models()[0]
.objects.child_of(self)
.live()
.order_by("title")
)
Upasanadhameliya marked this conversation as resolved.
Show resolved Hide resolved
return context
12 changes: 12 additions & 0 deletions project/hangouts/templates/hangouts/hangout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "base.html" %}

{% block title %}{{ page.title }}{% endblock title %}

{% load wagtailcore_tags %}

{% block content %}
<h1>{{ page.title }}</h1>

{{ page.description | richtext }}

{% endblock content %}
26 changes: 26 additions & 0 deletions project/hangouts/templates/hangouts/hangouts_index_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends "base.html" %}

{% block title %}{{ page.title }}{% endblock title %}

{% load wagtailcore_tags %}

{% block content %}
<h1>{{ page.title }}</h1>

{{ page.introduction | richtext }}

<div class="row mt-5">
{% for hangout in hangouts %}
<div class="col">
<div class="card mb-5" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">{{ hangout.title }}</h5>
{{ hangout.description | richtext | truncatewords:50 }}
<a href="{% pageurl hangout %}" class="stretched-link">Go somewhere</a>
</div>
</div>
</div>
{% endfor %}
</div>

{% endblock content %}
3 changes: 3 additions & 0 deletions project/hangouts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions project/hangouts/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
13 changes: 11 additions & 2 deletions project/home/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.core.exceptions import ObjectDoesNotExist
from django.db import models

from wagtail.core.models import Page
Expand Down Expand Up @@ -31,6 +32,14 @@ class HomePage(Page):
def get_context(self, request):
context = super().get_context(request)
# Get Respective page objects in context for redirection and links
context["invite_friends_page"] = InviteFriendsPage.objects.get()
context["chapters_index_page"] = ChaptersIndexPage.objects.get()
try:
context["invite_friends_page"] = InviteFriendsPage.objects.get()
except ObjectDoesNotExist:
context["invite_friends_page"] = None

try:
context["chapters_index_page"] = ChaptersIndexPage.objects.get()
except ObjectDoesNotExist:
context["chapters_index_page"] = None

return context
10 changes: 5 additions & 5 deletions project/home/templates/home/home_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ <h1>{{ block.value }}</h1>
{% endif %}
{% endfor %}

<div class="float-end">
{% with invite_friends_page=invite_friends_page %}
<div>
{% if invite_friends_page %}
<h2><a href="{% pageurl invite_friends_page %}">{{ invite_friends_page.title }}</a></h2>
{% endwith %}
{% endif %}
<br>
{% with chapters_index_page=chapters_index_page %}
{% if chapters_index_page %}
<h2><a href="{% pageurl chapters_index_page %}">{{ chapters_index_page.title }}</a></h2>
{% endwith %}
{% endif %}
</div>

{% endblock content %}