Rename 'main' to 'thoughts'

SQL to migrate the DB. Create migrations, migrate
`DELETE FROM django_content_type WHERE app_label='thoughts';`
`UPDATE django_content_type SET app_label='thoughts' WHERE app_label='main';`
`DROP TABLE thoughts_thought;`
`ALTER TABLE main_thought RENAME TO thoughts_thought;`
`DELETE FROM django_migrations WHERE app='main';`
Hopefully that's right, I'm not going to double check it or anything.
This commit is contained in:
Matthias Portzel 2022-04-30 13:33:57 -04:00
parent 34868bd0a5
commit 1defa2b92c
39 changed files with 30 additions and 30 deletions

2
README
View File

@ -12,7 +12,7 @@ Running in production requires a WSGI host, which is way beyond the scope of thi
Since both production and my local development instance have a large (500+) number of posts, behavior with a small number of posts is untested and undefined. I do know that the system assumes that there is at least one post, and the main page will error if that's not the case. Pull requests (or emailed git patches) to fix this or similar bugs would be accepted.
Disabling pagination is possible by editing ./main/pagination.py.
Disabling pagination is possible by editing ./thoughts/pagination.py.
After cloning, you should create a `.env` to define environment variables. Read whispermaphone/settings.py.
You can generate a SECRET_KEY with `python3 -c "import secrets; print(''.join([secrets.choice('abcdefghijklmnopqrstuvwxyz0123456789\!@#$%^&*(-_=+)') for i in range(50)]))"`.

View File

@ -7,7 +7,7 @@ from django.template.loader import render_to_string
from django.utils import timezone
django.setup()
from main.models import Thought
from thoughts.models import Thought
from jetforce import GeminiServer, JetforceApplication, Response, Status
@ -20,7 +20,7 @@ app = JetforceApplication()
def index(request):
thoughts = Thought.objects.order_by("-posted")
rendered_text = render_to_string("whispermaphone/index.gmi", {
rendered_text = render_to_string("thoughts/index.gmi", {
"thoughts": thoughts,
})

View File

@ -1,4 +1,4 @@
{% extends "whispermaphone/page.html" %}
{% extends "thoughts/page.html" %}
{% block title %}Search{% if query %} "{{ query }}"{% endif %}{% endblock %}

View File

@ -2,4 +2,4 @@ from django.apps import AppConfig
class MainConfig(AppConfig):
name = 'main'
name = "thoughts"

View File

@ -1,6 +1,6 @@
from django.contrib.syndication.views import Feed
from main.models import Thought
from thoughts.models import Thought
class MainFeed(Feed):

View File

@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0001_initial'),
('thoughts', '0001_initial'),
]
operations = [

View File

@ -5,7 +5,7 @@ import uuid
def add_uuids(apps, schema_editor):
Thought = apps.get_model("main", "Thought")
Thought = apps.get_model("thoughts", "Thought")
for thought in Thought.objects.all():
thought.uuid = uuid.uuid4()
thought.save()
@ -18,7 +18,7 @@ def reverse_add_uuids(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('main', '0002_auto_20200906_0324'),
('thoughts', '0002_auto_20200906_0324'),
]
operations = [

View File

@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0003_thought_uuid'),
('thoughts', '0003_thought_uuid'),
]
operations = [

View File

@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0004_thought_media'),
('thoughts', '0004_thought_media'),
]
operations = [

View File

@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0005_thought_media_alt'),
('thoughts', '0005_thought_media_alt'),
]
operations = [

View File

@ -2,7 +2,7 @@ from haystack import indexes
from .models import Thought
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/main/thought_text.txt")
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/thoughts/thought_text.txt")
posted = indexes.DateTimeField(model_attr="posted")
def get_model(self):

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 340 B

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,4 +1,4 @@
{% extends "whispermaphone/page.html" %}
{% extends "thoughts/page.html" %}
{% block title %}About{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "whispermaphone/page.html" %}
{% extends "thoughts/page.html" %}
{% load static %}
{% block title %}Thoughts{% endblock %}
@ -13,7 +13,7 @@
{% block head %}
<link rel="alternate" href="/feed" type="application/rss+xml" title="RSS">
<link href="{% static 'main/codehighlight.css' %}" rel="stylesheet">
<link href="{% static 'thoughts/codehighlight.css' %}" rel="stylesheet">
{% endblock %}
{% block main %}

View File

@ -1,10 +1,10 @@
{% extends "whispermaphone/page.html" %}
{% extends "thoughts/page.html" %}
{% load static %}
{% block title %}Post{% endblock %}
{% block head %}
<link href="{% static 'main/login.css' %}" rel="stylesheet">
<link href="{% static 'thoughts/login.css' %}" rel="stylesheet">
{% endblock %}
{% block navigation %}

View File

@ -6,7 +6,7 @@
<title>{% block title %}{% endblock %}</title>
{% load static %}
<link href="{% static 'main/main.css' %}" rel="stylesheet">
<link href="{% static 'thoughts/main.css' %}" rel="stylesheet">
{% block head %}{% endblock %}
<link rel="icon" sizes="192x192" href="{% static 'images/favicon-192x192.png'%}">

View File

@ -1,10 +1,10 @@
{% extends "whispermaphone/page.html" %}
{% extends "thoughts/page.html" %}
{% load static %}
{% block title %}Post{% endblock %}
{% block head %}
<link href="{% static 'main/post.css' %}" rel="stylesheet">
<link href="{% static 'thoughts/post.css' %}" rel="stylesheet">
{% endblock %}
{% block navigation %}

View File

@ -53,7 +53,7 @@ def index(request):
thoughts = requested_page.get_all_entries()
return render(request, "whispermaphone/index.html", {
return render(request, "thoughts/index.html", {
"thoughts": thoughts,
"highlighted": highlighted_uuid,
"authenticated": authenticated,
@ -75,7 +75,7 @@ def login(request):
# Returning 401 here causes `links` to always prompt for HTTP basic auth, which is annoying.
# But the alternative is not following the HTTP spec, so I think this is fine.
return render(request, "whispermaphone/login.html", status=401)
return render(request, "thoughts/login.html", status=401)
def post(request):
@ -111,7 +111,7 @@ def post(request):
except:
error_line = f"An unknown error occurred processing your request: {errors}"
return render(request, "whispermaphone/post.html", {
return render(request, "thoughts/post.html", {
"form": thought_form,
"form_error": error_line
}, status=400)
@ -156,13 +156,13 @@ def post(request):
return redirect(editing_thought)
return redirect("post")
return render(request, "whispermaphone/post.html", {
return render(request, "thoughts/post.html", {
"form": ThoughtForm(instance=editing_thought) if editing_thought else ThoughtForm(),
"editing": not not editing_thought,
})
def about(request):
return render(request, "whispermaphone/about.html", {
return render(request, "thoughts/about.html", {
"authenticated": check_authenticated(request)
})

View File

@ -45,7 +45,7 @@ INSTALLED_APPS = [
"haystack",
"main",
"thoughts",
]
HAYSTACK_SIGNAL_PROCESSOR = "haystack.signals.RealtimeSignalProcessor"
@ -80,7 +80,7 @@ TEMPLATES = [
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"main.settings_context_processor.add_settings"
"thoughts.settings_context_processor.add_settings"
],
},
},

View File

@ -1,8 +1,8 @@
from django.conf.urls.static import static
from django.urls import path, include
from main import views
from main.feed import MainFeed
from thoughts import views
from thoughts.feed import MainFeed
from whispermaphone import settings
from haystack.views import SearchView, search_view_factory