From 838112be0d079b9413f4e1b956b18ee8df5b3a5d Mon Sep 17 00:00:00 2001 From: Shane Frischkorn Date: Sat, 22 Feb 2014 13:38:18 +1000 Subject: [PATCH] Changes to the mineral practice page --- .idea/dataSources.ids | 163 +++++- .idea/dataSources.xml | 14 +- .idea/misc.xml | 2 +- .idea/rockviewer.iml | 9 +- .idea/workspace.xml | 392 +++++++-------- db.sqlite3 | Bin 172032 -> 172032 bytes three_d_viewer/models.py | 9 +- .../templates/three_d_viewer/base.html | 7 +- .../three_d_viewer/mineral_detail.html | 463 ++++++++++++++++++ .../three_d_viewer/minerals_practice.html | 38 +- three_d_viewer/urls.py | 3 +- three_d_viewer/views.py | 21 +- 12 files changed, 874 insertions(+), 247 deletions(-) create mode 100644 three_d_viewer/templates/three_d_viewer/mineral_detail.html diff --git a/.idea/dataSources.ids b/.idea/dataSources.ids index a7aa2ad..e2979cf 100644 --- a/.idea/dataSources.ids +++ b/.idea/dataSources.ids @@ -1,6 +1,165 @@ - - + + + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/db.sqlite3 + + + file://$USER_HOME$/.PyCharm30/config/jdbc-drivers/xerial-sqlite-license.txt + + + file://$USER_HOME$/.PyCharm30/config/jdbc-drivers/sqlite-jdbc-3.7.6.3-20110609.081603-3.jar + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + + + + +
+ + + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + +
\ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index f2c2c97..95d82fc 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,11 +1,17 @@ - + - sqlite.xerial org.sqlite.JDBC - jdbc:sqlite:H:\GitHub\rockviewer\db.sqlite3 - + jdbc:sqlite:$PROJECT_DIR$/db.sqlite3 + + + file://$USER_HOME$/.PyCharm30/config/jdbc-drivers/xerial-sqlite-license.txt + + + file://$USER_HOME$/.PyCharm30/config/jdbc-drivers/sqlite-jdbc-3.7.6.3-20110609.081603-3.jar + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 8823786..21955c8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/rockviewer.iml b/.idea/rockviewer.iml index 51c48ce..51ac604 100644 --- a/.idea/rockviewer.iml +++ b/.idea/rockviewer.iml @@ -11,11 +11,18 @@ - + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c679856..aebe4b0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,21 +2,18 @@ - - - - - - + + + - - - - - - - - + + + + + + + + @@ -39,37 +36,19 @@ - - - - - - - - - - + - - + + - - - - - - - - - - + @@ -78,16 +57,76 @@ - + + + + + + + + + + + + + + + + - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103,21 +142,30 @@ + + + - @@ -286,14 +334,6 @@ - - - - - + + + + + + - + - + - - + + - + + @@ -683,140 +712,117 @@ + + - + + - + - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - + - - - + - + - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/db.sqlite3 b/db.sqlite3 index bb152c796271bf578d9d92084c7cb2a1801767aa..e798f78f1efed868aedec95de47e43f82a4c835a 100644 GIT binary patch delta 2136 zcmai!Z%h+s9LMju0!K^l3ZfPZ2nb3MTb{e?_1Xr9rCO$4W3pt)7InUH%ZA%=S0({*PcOeG zcl~`o-|z3aSmvk=Z_X-xM_=PC=644mZa6kQef^QMx76M)6eO3>ON_21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Gw*wEWvgvvt8Lv4o!=ikWp{$$^SFnuw?d-*= zd|@g-RjFjNakV<0osCaUnwk08$Qk8axtvs^)tRxAR8h5{q6VqrrSwENazcytM+UWs zrnW|YyQRn?$^p`b_qq;AekX1FSd2L)P!6@s_TP8e;Y7-s-ZbC&Xf6{g>zTxoF|HT& zOrfrq#+HrI&y?I~p>B+)>Ut$x$&Ds7y_5>;l^wQ~d-sc@YXgY51n?T^!6p0;VWdLh z_#wVQHd-Buj#&vqKkOrqK;QB#U0gn&*Ye>a&DZ8bwT1dzt*mLqnT60`RXNwe7=fuR zn}}a9bRXWv9ss~6|J$QMCG@^M-m&m*_TmY2Lt7U2H_=mgjsLgoV*M}S1FpHYo9H!M zYyR*W9^!$7i*0X1apZ#wfP6)gxJLZ=Cwv?`U2j~+T$1#MbVs@(U3h=DOm9qT{;dl^ zb|opig$~TXu5Q>xn$L8h3z3^(;X~+XzDf$+gkKy1C<1;S4sh{aQgH7OJv+qJq;Qb= z4dJ2E$qgapO}R*wgEv&mJ# z4m(3eboIb~B3qH53O-#zR?PzoY~)+Pgdfp#ks492e|WC?#p3zmVm{z~zOw1n&Eayo z$P;;_e0E1}jL7^2BRl|(CXhAYLn`~z5_;ib%87K*P?f-cRa_SLwSR6+cMpMCOGJ%o z9~xlk?}Wdg$IDChrse`(PHU@yP9lfHmK&rlp@w-9b~0^6_z^m&i+8GBN;c8D;Nyen Lm00p;;fC#B6S?IB diff --git a/three_d_viewer/models.py b/three_d_viewer/models.py index bf9eb6f..aa5fc64 100644 --- a/three_d_viewer/models.py +++ b/three_d_viewer/models.py @@ -61,10 +61,11 @@ class Sample(CommonInfo): @property def url(self): - if isinstance(self, Mineral): - return 'three_d_viewer:mineral_detail' - else: - return 'three_d_viewer:detail' + return 'three_d_viewer:mineral_detail' + #if isinstance(self, Mineral): + # return 'three_d_viewer:mineral_detail' + #else: + # return 'three_d_viewer:detail' class Mineral(Sample): diff --git a/three_d_viewer/templates/three_d_viewer/base.html b/three_d_viewer/templates/three_d_viewer/base.html index 614eb2a..a1d7de9 100644 --- a/three_d_viewer/templates/three_d_viewer/base.html +++ b/three_d_viewer/templates/three_d_viewer/base.html @@ -5,12 +5,15 @@ 3DVOL - 3D Virtual Object Library + +{% block includes %} - + +{% endblock %} - +
-
- - - - - -
+ {% block mineral_detail %} + {% endblock %}
-
- -
+{% block 3dcontent %} +{% endblock %} {% endblock %} \ No newline at end of file diff --git a/three_d_viewer/urls.py b/three_d_viewer/urls.py index ec5eb61..da55011 100644 --- a/three_d_viewer/urls.py +++ b/three_d_viewer/urls.py @@ -10,7 +10,8 @@ urlpatterns = patterns( url(r'^minerals_theory/$', generic.TemplateView.as_view(template_name="three_d_viewer/minerals_theory.html"), name='minerals_theory'), url(r'^minerals_practice/$', views.MineralPracticeView.as_view(template_name="three_d_viewer/minerals_practice.html"), name='minerals_practice'), url(r'^minerals_selftest/$', generic.TemplateView.as_view(template_name="three_d_viewer/minerals_selftest.html"), name='minerals_selftest'), - url(r'^minerals/(?P\d+)/$', views.MineralPracticeView.as_view(), name='mineral_detail'), + url(r'^minerals/(?P\d+)/$', views.MineralDetailView.as_view(), name='mineral_detail'), + #url(r'^minerals/(?P\d+)/$', views.MineralPracticeView.as_view(), name='mineral_practice'), #url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'), #url(r'^minerals/(?P\d+)/$', views.MineralDetailView.as_view(), name='mineral_detail'), url(r'^media/(?P.*)$', 'django.views.static.serve', diff --git a/three_d_viewer/views.py b/three_d_viewer/views.py index d1d8e93..7b2b547 100644 --- a/three_d_viewer/views.py +++ b/three_d_viewer/views.py @@ -33,7 +33,6 @@ class MineralPracticeView(generic.ListView): def get_context_data(self, **kwargs): context = super(MineralPracticeView, self).get_context_data(**kwargs) cat = Category.objects.get(name='Minerals') - #context['active_samples'] = cat.active_samples result = cat.active_samples for child in cat.active_children: @@ -59,7 +58,7 @@ class DetailView(generic.DetailView): filter(active=True).order_by('name') return context -class MineralDetailView(DetailView): +class MineralDetailView(generic.DetailView): """ Add extra functionality for mineral details """ @@ -70,9 +69,19 @@ class MineralDetailView(DetailView): parent_categories = Category.objects.filter(parent=None). \ filter(active=True).order_by("name") + #def get_context_data(self, **kwargs): + # context = super(MineralDetailView, self).get_context_data(**kwargs) + # context['active_samples'] = Sample.objects.select_subclasses(Mineral).filter(active=True).order_by('name') + # context['parent_categories'] = Category.objects.filter(parent=None). \ + # filter(active=True).order_by('name') + # return context def get_context_data(self, **kwargs): - context = super(DetailView, self).get_context_data(**kwargs) - context['active_samples'] = Sample.objects.select_subclasses(Mineral).filter(active=True).order_by('name') - context['parent_categories'] = Category.objects.filter(parent=None). \ - filter(active=True).order_by('name') + context = super(MineralDetailView, self).get_context_data(**kwargs) + cat = Category.objects.get(name='Minerals') + result = cat.active_samples + + for child in cat.active_children: + result = chain(result, child.active_samples) + + context['active_samples'] = sorted(result, key=attrgetter('name')) return context \ No newline at end of file