Skip to content

Commit b9434d2

Browse files
committed
Merge master
2 parents aa233ae + 8bd6545 commit b9434d2

3 files changed

Lines changed: 40 additions & 42 deletions

File tree

‎packages/djangobuilder.io/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"stylus": "^0.55.0",
5858
"stylus-loader": "^6.1.0",
5959
"unplugin-vue-components": "^0.22.4",
60-
"vite": "^2.5.4",
60+
"vite": "^2.9.16",
6161
"vite-plugin-vue2": "1.9.0",
6262
"vitest": "^0.24.3",
6363
"vue-cli-plugin-vuetify": "^2.4.2",

‎packages/djangobuilder.io/src/django/rendering.js‎

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class Renderer {
220220

221221
if (app == undefined) return
222222

223-
const models = this.get_models(app_id)
223+
const models = this.get_concrete_models(app_id)
224224

225225
let model_templates = []
226226

@@ -455,6 +455,12 @@ class Renderer {
455455
return this.store.getters.ordered_models(appid)
456456
}
457457

458+
// Only return non-abstract models, so Django won't try to use
459+
// abstract models in admin panel (admin.py), serialize.py, etc.
460+
get_concrete_models(appid) {
461+
return this.get_models(appid).filter(model => !model.abstract)
462+
}
463+
458464
get_fields(model) {
459465
return keys(model.fields).map((field) => {
460466
return this.store.getters.fields()[field] ? this.store.getters.fields()[field].data() : [];
@@ -615,7 +621,7 @@ CHANNEL_LAYERS = {
615621

616622
apps.forEach((app) => {
617623
output += `\n<div class="m-2"><h4>${app.name}</h4></div>`
618-
this.get_models(app.id).forEach((model) => {
624+
this.get_concrete_models(app.id).forEach((model) => {
619625
output += `\n<div class="m-2"><a class="btn btn-light" href="{% url '${app.name}_${model.name}_list' %}">${model.name} Listing</a></div>`
620626
})
621627
})
@@ -639,7 +645,7 @@ CHANNEL_LAYERS = {
639645
const apps = this.get_apps(projectid);
640646
let htmx_body = ""
641647
apps.forEach((app) => {
642-
const models = this.get_models(app.id)
648+
const models = this.get_concrete_models(app.id)
643649
models.forEach((model) => {
644650
htmx_body += `
645651
<div class="col col-lg-6">
@@ -907,7 +913,7 @@ CHANNEL_LAYERS = {
907913
urls += '\n\n'
908914
urls += 'router = routers.DefaultRouter()\n'
909915

910-
const models = this.get_models(appid)
916+
const models = this.get_concrete_models(appid)
911917

912918
models.forEach((model) => {
913919
urls += 'router.register("' + model.name + '", api.' + model.name + 'ViewSet)\n'
@@ -965,7 +971,8 @@ CHANNEL_LAYERS = {
965971
api += 'from . import serializers\n'
966972
api += 'from . import models\n'
967973

968-
const models = this.get_models(appid)
974+
const models = this.get_concrete_models(appid)
975+
969976

970977
models.forEach((model) => {
971978
api += '\n\n'
@@ -984,7 +991,7 @@ CHANNEL_LAYERS = {
984991
serializers += '\n'
985992
serializers += 'from . import models\n'
986993

987-
const models = this.get_models(appid)
994+
const models = this.get_concrete_models(appid)
988995

989996
models.forEach((model) => {
990997
const fields = this.get_fields(model)
@@ -1014,7 +1021,7 @@ CHANNEL_LAYERS = {
10141021
admin += 'from . import models\n'
10151022
admin += '\n\n'
10161023

1017-
const models = this.get_models(appid)
1024+
const models = this.get_concrete_models(appid)
10181025

10191026
models.forEach((model) => {
10201027
admin += 'class ' + model.name + 'AdminForm(forms.ModelForm):\n'
@@ -1188,10 +1195,8 @@ CHANNEL_LAYERS = {
11881195
}
11891196

11901197
views_py(projectid, appid) {
1191-
const models = this.get_models(appid).filter((modelData)=> {
1192-
// Do not include abstract models in form views
1193-
return !modelData.abstract
1194-
})
1198+
// Do not include abstract models in form views
1199+
const models = this.get_concrete_models(appid)
11951200

11961201
const appData = this.store.getters.appData(appid)
11971202

@@ -1228,10 +1233,8 @@ CHANNEL_LAYERS = {
12281233
htmx_py (projectid, appid) {
12291234
const appData = this.store.getters.appData(appid)
12301235

1231-
const models = this.get_models(appid).filter((modelData)=> {
1232-
// Do not include abstract models in form views
1233-
return !modelData.abstract
1234-
})
1236+
// Do not include abstract models in form views
1237+
const models = this.get_concrete_models(appid)
12351238

12361239
let htmx_views = 'from django.views import generic\n'
12371240
htmx_views += 'from django.urls import reverse_lazy\n'
@@ -1268,10 +1271,8 @@ CHANNEL_LAYERS = {
12681271
}
12691272

12701273
forms_py(projectid, appid) {
1271-
const models = this.get_models(appid).filter((modelData)=> {
1272-
// Do not include abstract models in forms
1273-
return !modelData.abstract
1274-
})
1274+
// Do not include abstract models in forms
1275+
const models = this.get_concrete_models(appid)
12751276

12761277
let forms = 'from django import forms'
12771278

@@ -1372,9 +1373,7 @@ CHANNEL_LAYERS = {
13721373
const extra_imports = new Set()
13731374

13741375
apps.forEach((app) => {
1375-
const models = this.get_models(app.id).filter((modelData)=> {
1376-
return !modelData.abstract
1377-
})
1376+
const models = this.get_concrete_models(app.id)
13781377
models.forEach((model) => {
13791378
const parent_user_models = []
13801379
const parent_django_models = []
@@ -1457,9 +1456,8 @@ CHANNEL_LAYERS = {
14571456
tests += '\n\n'
14581457
tests += 'pytestmark = [pytest.mark.django_db]\n'
14591458

1460-
const models = this.get_models(appid).filter((modelData)=> {
1461-
return !modelData.abstract
1462-
})
1459+
const models = this.get_concrete_models(appid)
1460+
14631461
models.forEach((model) => {
14641462
tests += '\n\n'
14651463

‎yarn.lock‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,9 +2024,9 @@
20242024
"@hapi/hoek" "^9.0.0"
20252025

20262026
"@sideway/formula@^3.0.0":
2027-
version "3.0.0"
2028-
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c"
2029-
integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg==
2027+
version "3.0.1"
2028+
resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.1.tgz#80fcbcbaf7ce031e0ef2dd29b1bfc7c3f583611f"
2029+
integrity sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==
20302030

20312031
"@sideway/formula@^3.0.1":
20322032
version "3.0.1"
@@ -5006,9 +5006,9 @@ decimal.js@^10.4.2:
50065006
integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==
50075007

50085008
decode-uri-component@^0.2.0:
5009-
version "0.2.0"
5010-
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
5011-
integrity sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==
5009+
version "0.2.2"
5010+
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
5011+
integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==
50125012

50135013
decompress-response@^3.3.0:
50145014
version "3.3.0"
@@ -7223,9 +7223,9 @@ html-tags@^3.1.0:
72237223
integrity sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg==
72247224

72257225
http-cache-semantics@^4.0.0, http-cache-semantics@^4.1.0:
7226-
version "4.1.0"
7227-
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390"
7228-
integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==
7226+
version "4.1.1"
7227+
resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a"
7228+
integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==
72297229

72307230
http-errors@2.0.0:
72317231
version "2.0.0"
@@ -12275,10 +12275,10 @@ vite-plugin-vue2@1.9.0:
1227512275
source-map "^0.7.3"
1227612276
vue-template-es2015-compiler "^1.9.1"
1227712277

12278-
vite@^2.5.4:
12279-
version "2.9.15"
12280-
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.15.tgz#2858dd5b2be26aa394a283e62324281892546f0b"
12281-
integrity sha512-fzMt2jK4vQ3yK56te3Kqpkaeq9DkcZfBbzHwYpobasvgYmP2SoAr6Aic05CsB4CzCZbsDv4sujX3pkEGhLabVQ==
12278+
vite@^2.9.16:
12279+
version "2.9.16"
12280+
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.16.tgz#daf7ba50f5cc37a7bf51b118ba06bc36e97898e9"
12281+
integrity sha512-X+6q8KPyeuBvTQV8AVSnKDvXoBMnTx8zxh54sOwmmuOdxkjMmEJXH2UEchA+vTMps1xw9vL64uwJOWryULg7nA==
1228212282
dependencies:
1228312283
esbuild "^0.14.27"
1228412284
postcss "^8.4.13"
@@ -12344,9 +12344,9 @@ vitest@^0.24.3:
1234412344
vite "^3.0.0"
1234512345

1234612346
vm2@^3.9.8:
12347-
version "3.9.11"
12348-
resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.11.tgz#a880f510a606481719ec3f9803b940c5805a06fe"
12349-
integrity sha512-PFG8iJRSjvvBdisowQ7iVF580DXb1uCIiGaXgm7tynMR1uTBlv7UJlB1zdv5KJ+Tmq1f0Upnj3fayoEOPpCBKg==
12347+
version "3.9.19"
12348+
resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.19.tgz#be1e1d7a106122c6c492b4d51c2e8b93d3ed6a4a"
12349+
integrity sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==
1235012350
dependencies:
1235112351
acorn "^8.7.0"
1235212352
acorn-walk "^8.2.0"

0 commit comments

Comments
 (0)