-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Topic landing pools sql #2110
base: topic-landing-pools
Are you sure you want to change the base?
Topic landing pools sql #2110
Conversation
…represent many to many relationship
@@ -0,0 +1,99 @@ | |||
from django.contrib import admin, messages | |||
from django_topics.models import Topic, TopicPool | |||
from django_topics.models.pool import PoolType |
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.
You can import PoolType
directly fromdjango_topics.models
since you've already imported it there from the sub-file
|
||
def delete_all_data(): | ||
print("Delete data") | ||
Topic.pools.through.objects.all().delete() |
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.
The explicit deletion of the through model records is not strictly needed.
On intermediate through models in a m2m relationship, the default behavior when deleting either of the related models is to delete the associated records in the through model as well (the on_delete
parameter of the ForeignKey defaults to CASCADE
)
Your call if it's clearer to keep it in or not.
@@ -50,7 +50,7 @@ class Header extends Component { | |||
{ Sefaria._siteSettings.TORAH_SPECIFIC ? | |||
<a className="home" href="/" >{logo}</a> : null } | |||
<a href="/texts" className="textLink"><InterfaceText context="Header">Texts</InterfaceText></a> | |||
<a href="/topics" className="textLink"><InterfaceText>Topics</InterfaceText></a> | |||
<a href="/django_topics" className="textLink"><InterfaceText>Topics</InterfaceText></a> |
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.
I think this (and all the diffs below changing /topics
to /django_topics
) might be a mistake... It doesn't seem like we set any route for this URL.
Maybe an errant find/replace?
Description
Introduces the
TopicPoolLink
model, the first time we're using Django models in the system.pool
andtopic_slug
fields.PoolType
Enum for defining pool types (TEXTUAL
,SHEETS
,PROMOTED
).admin_tools
inINSTALLED_APPS
.Also refactors
get_random_topic
and related functions to utilizeTopicPoolLink
, as a proof-of-concept for TopicPoolLink IRL.