-
Notifications
You must be signed in to change notification settings - Fork 38
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
Update homepage to not used wagtail pages #4127
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
from urllib.parse import urljoin | ||
|
||
from django.urls import reverse | ||
from django.utils.translation import gettext as _ | ||
from wagtail import hooks | ||
from wagtail.admin.menu import MenuItem | ||
|
||
from hypha.home.models import ApplyHomePage | ||
|
||
|
||
@hooks.register("register_admin_menu_item") | ||
def register_dashboard_menu_item(): | ||
apply_home = ApplyHomePage.objects.first() | ||
return MenuItem( | ||
"Apply Dashboard", | ||
urljoin(apply_home.url, reverse("dashboard:dashboard", "hypha.urls")), | ||
_("Goto Dashboard"), | ||
reverse("dashboard:dashboard"), | ||
classname="icon icon-arrow-left", | ||
order=100000, | ||
) |
32 changes: 32 additions & 0 deletions
32
hypha/core/migrations/0006_systemsettings_home_strapline_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 4.2.16 on 2024-09-10 07:30 | ||
|
||
from django.db import migrations, models | ||
import wagtail.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0005_alter_systemsettings_footer_content"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="systemsettings", | ||
name="home_strapline", | ||
field=wagtail.fields.RichTextField( | ||
default="", | ||
help_text="The strapline to be displayed on the homepage.", | ||
verbose_name="Strapline", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="systemsettings", | ||
name="home_title", | ||
field=models.CharField( | ||
default="", | ||
help_text="The title to be displayed on the homepage.", | ||
max_length=255, | ||
verbose_name="Title", | ||
), | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
hypha/core/migrations/0007_copy_homepage_title_strapline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.16 on 2024-09-10 07:34 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
def copy_homepage_title_and_strapline(apps, schema_editor): | ||
from hypha.core.models import SystemSettings | ||
from hypha.home.models import ApplyHomePage | ||
|
||
if home_page := ApplyHomePage.objects.first(): | ||
system_settings = SystemSettings.load() | ||
system_settings.home_title = home_page.title | ||
system_settings.home_strapline = home_page.strapline | ||
system_settings.save() | ||
|
||
dependencies = [ | ||
("core", "0006_systemsettings_home_strapline_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(copy_homepage_title_and_strapline), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "base-apply.html" %} | ||
{% load nh3_tags %} | ||
|
||
{% block title_prefix %}{{ settings.core.SystemSettings.home_title }} | {% endblock %} | ||
{% block title %}{{ ORG_SHORT_NAME }}{% endblock %} | ||
{% block meta_description %}{{ settings.core.SystemSettings.home_strapline|striptags|truncatechars:200 }}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="py-8 lg:py-16 max-w-3xl mx-auto"> | ||
|
||
<h1 class="font-bold text-5xl text-balance"> | ||
{{ settings.core.SystemSettings.home_title}} | ||
</h1> | ||
|
||
{% if settings.core.SystemSettings.home_strapline %} | ||
<p class="mb-8 text-fg-muted text-pretty">{{ settings.core.SystemSettings.home_strapline|nh3|safe }}</p> | ||
{% endif %} | ||
|
||
<div class="divide-y"> | ||
{% for fund in funds %} | ||
{% include "home/includes/fund-list-item.html" with page=fund %} | ||
{% endfor %} | ||
</div> | ||
|
||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
# from django.shortcuts import render | ||
from django.shortcuts import render | ||
|
||
# Create your views here. | ||
from hypha.apply.funds.models import ApplicationBase, LabBase | ||
|
||
|
||
def home(request): | ||
"""Home page view. | ||
|
||
Displays the list of active rounds and labs to both logged in and logged out users. | ||
""" | ||
ctx = {} | ||
rounds = ApplicationBase.objects.order_by_end_date().specific() | ||
labs = LabBase.objects.public().live().specific() | ||
|
||
ctx["funds"] = list(rounds) + list(labs) | ||
return render(request, "home/home.html", ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.sidebar form[role="search"] { | ||
.sidebar form[role="search"], | ||
.sidebar-page-explorer-item { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line makes the code in
copy_homepage_title_and_strapline
not run since the model no longer have a strapline.Would be really good to get this working making the deployment of this release seamless.
Maybe we can remove the strapline field in a separate release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right,
hasattr
will always be false. I think we can remove it later after couple of releases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the code so that it keeps the strapline on the ApplyHome model.