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

Don't generate entries for Abstract Models in more areas (Fixes #194) #197

Merged
Merged
Changes from 5 commits
Commits
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
15 changes: 8 additions & 7 deletions src/django/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class Renderer {

if (app == undefined) return

const models = this.get_models(app_id)
const models = this.get_models(app_id).filter(model => !model.abstract)
Copy link
Owner

@mmcardle mmcardle Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i think at this point we should create a new function

get_concrete_models(appid) {
  return this.get_models(appid).filter(model => !model.abstract)
}

and use it everywhere you have it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes perfect sense, will do!


let model_templates = []

Expand Down Expand Up @@ -615,7 +615,7 @@ CHANNEL_LAYERS = {

apps.forEach((app) => {
output += `\n<div class="m-2"><h4>${app.name}</h4></div>`
this.get_models(app.id).forEach((model) => {
this.get_models(app.id).filter(model => !model.abstract).forEach((model) => {
output += `\n<div class="m-2"><a class="btn btn-light" href="{% url '${app.name}_${model.name}_list' %}">${model.name} Listing</a></div>`
})
})
Expand All @@ -639,7 +639,7 @@ CHANNEL_LAYERS = {
const apps = this.get_apps(projectid);
let htmx_body = ""
apps.forEach((app) => {
const models = this.get_models(app.id)
const models = this.get_models(app.id).filter(model => !model.abstract)
models.forEach((model) => {
htmx_body += `
<div class="col col-lg-6">
Expand Down Expand Up @@ -907,7 +907,7 @@ CHANNEL_LAYERS = {
urls += '\n\n'
urls += 'router = routers.DefaultRouter()\n'

const models = this.get_models(appid)
const models = this.get_models(appid).filter(model => !model.abstract)

models.forEach((model) => {
urls += 'router.register("' + model.name + '", api.' + model.name + 'ViewSet)\n'
Expand Down Expand Up @@ -965,7 +965,8 @@ CHANNEL_LAYERS = {
api += 'from . import serializers\n'
api += 'from . import models\n'

const models = this.get_models(appid)
const models = this.get_models(appid).filter(model => !model.abstract)


models.forEach((model) => {
api += '\n\n'
Expand All @@ -984,7 +985,7 @@ CHANNEL_LAYERS = {
serializers += '\n'
serializers += 'from . import models\n'

const models = this.get_models(appid)
const models = this.get_models(appid).filter(model => !model.abstract)

models.forEach((model) => {
const fields = this.get_fields(model)
Expand Down Expand Up @@ -1014,7 +1015,7 @@ CHANNEL_LAYERS = {
admin += 'from . import models\n'
admin += '\n\n'

const models = this.get_models(appid).filter(model => !model.abstract);
const models = this.get_models(appid).filter(model => !model.abstract)

models.forEach((model) => {
admin += 'class ' + model.name + 'AdminForm(forms.ModelForm):\n'
Expand Down