From 3dfe03216c0dfde30fb4696f78b06f436ae1cb47 Mon Sep 17 00:00:00 2001 From: Shane Frischkorn Date: Mon, 24 Nov 2014 14:32:56 +1000 Subject: [PATCH] Implemented erb101 menu --- db.sqlite3 | Bin 180224 -> 180224 bytes three_d_viewer/models.py | 8 +- .../templates/three_d_viewer/base.html | 2 + .../templates/three_d_viewer/erb101/base.html | 12 ++- .../templates/three_d_viewer/erb101/home.html | 14 +++- .../three_d_viewer/erb101/mineral_detail.html | 1 + .../erb101/minerals_practice.html | 1 + .../three_d_viewer/erb101/rock_detail.html | 3 + .../three_d_viewer/erb101/rock_practice.html | 2 - .../three_d_viewer/erb101/theory/bowen.html | 26 ++++++ .../erb101/theory/pressure_temp.html | 56 +++++++++++++ .../erb101/theory/structure.html | 37 +++++++++ .../templates/three_d_viewer/rock_detail.html | 3 +- .../three_d_viewer/sample_detail.html | 1 + .../three_d_viewer/sample_practice.html | 6 +- .../three_d_viewer/theory/bowen.html | 2 +- .../three_d_viewer/theory/pressure_temp.html | 2 +- .../three_d_viewer/theory/structure.html | 2 +- three_d_viewer/urls.py | 11 ++- three_d_viewer/views.py | 78 +++++++++++++++++- 20 files changed, 247 insertions(+), 20 deletions(-) create mode 100644 three_d_viewer/templates/three_d_viewer/erb101/mineral_detail.html create mode 100644 three_d_viewer/templates/three_d_viewer/erb101/minerals_practice.html create mode 100644 three_d_viewer/templates/three_d_viewer/erb101/rock_detail.html create mode 100644 three_d_viewer/templates/three_d_viewer/erb101/theory/bowen.html create mode 100644 three_d_viewer/templates/three_d_viewer/erb101/theory/pressure_temp.html create mode 100644 three_d_viewer/templates/three_d_viewer/erb101/theory/structure.html diff --git a/db.sqlite3 b/db.sqlite3 index 2322361f62683b1edf9646f6fe6f2ad9635535e0..7d139fafbc1adecce5cfb4f19bed2caf8942d54f 100644 GIT binary patch delta 887 zcmaiwT}V@57{}lD*`|BldCy6jPSfnnP0eh2&T+Qr1JcwmJ)7FnO(@v>+SFyGuG-Zs zD?&k`i9lRG z2;aI>d@K`EBuR1yyQQ||q1w>6GLm%ns6nM=B67I3^<>qU?~K$RZtx{1Qm0Ndw0B8I zIs@TUDs*%#)X>*Cx?hoGuSb?WidU56J+<;4*;g$|hUdbIOs!NxP4h^|;qA19+ip{G z_K{|5dv;IONy{bkb<_MpWYe7K_~c-|MLmD4-Z$tSlOoaDx>z(haV8pz4iB6iAFey6 zSE+bkUDU61B?8@DF@Ix|R}K0T>QGBc4R)MWhlahX(j50U4$G<%J{Q(?ztR~~Q%y?G z(AB43N4JKg-=vC1+Wm)AR(uBO_0KUIN9i}ji~OwMqTlZFc%3ql$7bjMpz<|+?EO*+ z1tT>dnHEFin%f z0sYTj@fuyH%k&yoPXkn>n0w0I!mKSKA(XJ^ z_aL90Zv#6nV5|+Qf&0WBwn4c_GssSfOW!DhgOQQm_;`Qy)?(e|mu6xei?BJ%Q$$D; zVev(%M#gg&5@BY zH?N;)WuqAoWrR@aZBVaJTIr@ zcG)M3Y=gaI_t;{-L>pp!cpch}+v{*7xi<|=;T8F;tece|m_aw`GrCN(w2hXKALI?W zORkbMnIw~@HAKYSv`odAV*d6q+QDZ#kptQ|??m;868^jsRg-czh7@}s1}?PAbox|)A%>~q2`1cs9 zf+A;eIO1NQ@fQ7tuRte7uahpdeYm=bK4o-3Tn8weTNNRG>Bh diff --git a/three_d_viewer/models.py b/three_d_viewer/models.py index 0c838f7..f3c944a 100644 --- a/three_d_viewer/models.py +++ b/three_d_viewer/models.py @@ -81,11 +81,11 @@ class Sample(CommonInfo): self.viewed_count += 1 if cat.name == 'Fossils': - return 'three_d_viewer:fossil_detail' + return 'fossil_detail' elif cat.name == 'Rocks': - return 'three_d_viewer:rock_detail' + return 'rock_detail' else: - return 'three_d_viewer:sample_detail' + return 'sample_detail' class Mineral(Sample): @@ -107,7 +107,7 @@ class Mineral(Sample): @property def url(self): self.viewed_count += 1 - return 'three_d_viewer:mineral_detail' + return 'mineral_detail' class Question(models.Model): diff --git a/three_d_viewer/templates/three_d_viewer/base.html b/three_d_viewer/templates/three_d_viewer/base.html index aa68510..a2d1852 100644 --- a/three_d_viewer/templates/three_d_viewer/base.html +++ b/three_d_viewer/templates/three_d_viewer/base.html @@ -31,9 +31,11 @@
  • Theory
  • {% block mineral_practice %}
  • Practice
  • {% endblock %} diff --git a/three_d_viewer/templates/three_d_viewer/erb101/base.html b/three_d_viewer/templates/three_d_viewer/erb101/base.html index c34b962..8fa4237 100644 --- a/three_d_viewer/templates/three_d_viewer/erb101/base.html +++ b/three_d_viewer/templates/three_d_viewer/erb101/base.html @@ -14,4 +14,14 @@ {% endblock %} {% block fossil_menu %} -{% endblock %} \ No newline at end of file +{% endblock %} + +{% block theory %} +
  • Structure of Earth
  • +
  • Pressure and temperature
  • +
  • Bowen's reaction series
  • +{% endblock %} + + \ No newline at end of file diff --git a/three_d_viewer/templates/three_d_viewer/erb101/home.html b/three_d_viewer/templates/three_d_viewer/erb101/home.html index 5a2b4cb..1dfb466 100644 --- a/three_d_viewer/templates/three_d_viewer/erb101/home.html +++ b/three_d_viewer/templates/three_d_viewer/erb101/home.html @@ -3,9 +3,19 @@ {% block content %}
    -

    ERB101 home page



    +

    ERB101 - Earth Systems



    - blah blah blah + Earth Science impacts every aspect of modern life. Hence, the concepts of Earth Science +are fundamental not only to the field of Geology, but also to Environmental Science, natural +resource management, civil engineering and society at large. Earth Systems provides an +introduction to Earth Science, including earth materials, geologic history, geological and +physical geography process at the Earth's surface, and the complex interplay between the +lithosphere and landscapes. Additionally, the unit provides readily accessible examples of +the use of scientific reasoning for understanding complex natural systems. Hence, Earth +Systems is a foundation unit for further studies in Geology and Environmental Science, but +more importantly, serves as a broad introduction to the very world we live on and to the ways +of science in general. Such a background is highly desirable for any informed citizenry for +understanding complex issues of resource, environment, and societal development.

    {% endblock %} \ No newline at end of file diff --git a/three_d_viewer/templates/three_d_viewer/erb101/mineral_detail.html b/three_d_viewer/templates/three_d_viewer/erb101/mineral_detail.html new file mode 100644 index 0000000..439b289 --- /dev/null +++ b/three_d_viewer/templates/three_d_viewer/erb101/mineral_detail.html @@ -0,0 +1 @@ +{% extends "three_d_viewer/mineral_detail.html" %} \ No newline at end of file diff --git a/three_d_viewer/templates/three_d_viewer/erb101/minerals_practice.html b/three_d_viewer/templates/three_d_viewer/erb101/minerals_practice.html new file mode 100644 index 0000000..568a07a --- /dev/null +++ b/three_d_viewer/templates/three_d_viewer/erb101/minerals_practice.html @@ -0,0 +1 @@ +{% extends "three_d_viewer/minerals_practice.html" %} \ No newline at end of file diff --git a/three_d_viewer/templates/three_d_viewer/erb101/rock_detail.html b/three_d_viewer/templates/three_d_viewer/erb101/rock_detail.html new file mode 100644 index 0000000..239235a --- /dev/null +++ b/three_d_viewer/templates/three_d_viewer/erb101/rock_detail.html @@ -0,0 +1,3 @@ +{% extends "three_d_viewer/rock_detail.html" %} + + diff --git a/three_d_viewer/templates/three_d_viewer/erb101/rock_practice.html b/three_d_viewer/templates/three_d_viewer/erb101/rock_practice.html index 3d8e52e..993193d 100644 --- a/three_d_viewer/templates/three_d_viewer/erb101/rock_practice.html +++ b/three_d_viewer/templates/three_d_viewer/erb101/rock_practice.html @@ -1,3 +1 @@ {% extends "three_d_viewer/rock_practice.html" %} - -{% block base %}{% extends "three_d_viewer/erb101/base.html" %}{% endblock %} \ No newline at end of file diff --git a/three_d_viewer/templates/three_d_viewer/erb101/theory/bowen.html b/three_d_viewer/templates/three_d_viewer/erb101/theory/bowen.html new file mode 100644 index 0000000..483f9b5 --- /dev/null +++ b/three_d_viewer/templates/three_d_viewer/erb101/theory/bowen.html @@ -0,0 +1,26 @@ +{% extends "three_d_viewer/base.html" %} +{% load static %} + +{% block content %} +
    +
    +

    Theory

    +

    Bowen's Reaction Series

    +

    + Bowen's Reaction Series arranges the silicate minerals in the order that they crystallise from a magma. The minerals at the top of the series crystallise from the melt at higher temperature than those + lower down. It contains a continuous series, (right hand limb), discontinuous series (left hand limb), and the residual phases that describe the reaction pathway of different silicate minerals. + The discontinuous series crystallises different minerals, with abrupt changes separating the different minerals due to a mineral reacting with the melt to form a different mineral (eg. Olivine reacting to crystallise pyroxene). + The continuous series always crystallises plagioclase, but the composition of the plagioclase varies from more calcic at higher temperatures and more sodic as the temperature decreases. + with the minerals at the bottom of the series being more stable, and less susceptible to weathering. + The residual phases are the minerals at the bottom and crystallise last. Bowen's reaction series also predicts the stability of minerals in the low pressure conditions at the Earth's surface, +

    + It should be noted that all reactions do not start crystallising olivine/anorthite-rich plagioclase and continue through until they crystallise quartz. + The actual reactions depend on many factors, such as the chemical composition of the melt, temperature, pressure, and amount of fractional crystallisation. + For example, basalts form from the crystallisation of olivine, pyroxene and calcic plagioclase meaning that crystallisation stopped without the series progressing. + If more fractional crystallisation were to occur, more intermediate and felsic minerals can crystallise. +
    + +

    +
    +
    +{% endblock %} diff --git a/three_d_viewer/templates/three_d_viewer/erb101/theory/pressure_temp.html b/three_d_viewer/templates/three_d_viewer/erb101/theory/pressure_temp.html new file mode 100644 index 0000000..edc2d4c --- /dev/null +++ b/three_d_viewer/templates/three_d_viewer/erb101/theory/pressure_temp.html @@ -0,0 +1,56 @@ +{% extends "three_d_viewer/base.html" %} +{% load static %} + +{% block content %} +
    +
    +

    Theory

    +

    Pressure and Temperature

    +

    + The heat contained within the Earth is generated by two main sources: the formation of the Earth, + and the decay of radioactive isotopes. The Earth was formed by the accretion of a large number of + planitesimals as it cleared its orbit. The impact of those planitesimals generated a large amount + of heat which is still being lost from the Earth’s core today. The other source of heat comes + from the radioactive decay of elements within the crust and mantle of the Earth. + The primary radioactive isotopes in the Earth are uranium-235, uranium-238, thorium-232, + and potassium-40. Radioactive decay is the dominant form of heat flow at the surface of the Earth, + providing approximately 80% of the heat budget. +

    + The temperature of the Earth changes from around 0°C at the surface to over 5000°C in the core. + The geothermal gradient in the crust is approximately 30°C per kilometre in the crust on average, + however there is significant local variation due to things such as the conductive abilities of the + rocks at particular locations, as well as the presence of nearby magmatic intrusions. + The geothermal gradient in the mantle reduces significantly, down to approximately 0.3°C/km. + The base of the lithosphere is defined by the 1000°C isotherm. The base of the mantle is at + approximately 2800°C. +

    + The method of heat transfer changes throughout the Earth. There are three main mechanisms for + heat transfer in the Earth: conduction, convection, and radiation. Starting in the inner core, + the main method of heat transfer is by conduction through the solid material. In the liquid, + outer core heat transfer is by both conduction and convection. The mantle is dominated by convection, + which is the driver of plate tectonics. The crust is again dominated by conduction, and finally + energy escapes the Earth to the atmosphere by radiation. +

    + Pressure in the Earth continually increases with depth, according to the formula P = gρz, + where g is the gravitation field strength, ρ is the density and z is the depth. The main + difference in the pressure gradient is cause by the different lithologies in the layers + of the Earth. The average density of continental crust is approximately 2.7g/cm3 and + is ~3.0 g/cm3 in oceanic crust, and increases to about 3.3 g/cm3 in the mantle. + The increase of pressure with depth in the Earth affects the dominant mineralogy, as + well as the increase of the melting point of different minerals. +

    + The structure of minerals, such as olivine becomes unstable as pressure increases. + Below about 410km olivine becomes unstable and transforms into wadsleyite, which has the + same chemical composition as olivine, but has a different crystal structure. As depth + increases, wadsleyite transforms to ringwoodite, which subsequently transforms into + perovskite at about 600km. +

    + At higher pressure, minerals have a higher melting point. The effect is this phenomenon + is that the dominant method of melting in the mantle is not by increasing the temperature + past its melting point, but by decompression. Due to convective processes in the mantle, + as parts of the mantle rise the decrease in pressure lowers the melting temperature and + can cause the mantle to melt. +

    +
    +
    +{% endblock %} diff --git a/three_d_viewer/templates/three_d_viewer/erb101/theory/structure.html b/three_d_viewer/templates/three_d_viewer/erb101/theory/structure.html new file mode 100644 index 0000000..2363fff --- /dev/null +++ b/three_d_viewer/templates/three_d_viewer/erb101/theory/structure.html @@ -0,0 +1,37 @@ +{% extends "three_d_viewer/base.html" %} +{% load static %} + +{% block content %} +
    +
    +

    Theory

    +

    Structure of Earth

    +

    + The Earth's structure is differentiated in three distinct layers: the core, mantle, and crust. The layers are distinguished by a change in the velocity of seismic waves at their boundaries. + The crust is the upper most part of the earth, with depths ranging from an average of 7km in in the oceans, to an average of 38km in continental crust. + The crust thickens underneath mountain ranges, and can reach depths of 90km underneath the Himalayas. The composition of the crust also differs between oceanic and + continental environments. Ocean crust is young mafic crust dominated by basalts and gabbros that is recycled regularly(~300Ma) due to subduction processes. + Continental crust is much more varied in structure and composition than oceanic, but has an overall average composition of granodiorite. +

    + The boundary of the crust and mantle is defined by the Mohorovi?i? discontinuity, commonly referred to as the Moho. + It is defined by a sharp increase in seismic wave velocity, due to a change in material properties between crustal rocks and mantle rocks. The mantle is dominated by + silicate minerals that are rich in iron and magnesium, chiefly pyroxenes and polymorphs of olivine, forming peridotite. The mantle, while solid, behaves plastically, + allowing to flow at very slow rates. +

    + The core is distinguished by the absence of S waves, leading to the inference that the core is liquid. The core is separated into the outer core and the inner core. + The outer core is liquid dominated by iron and nickel. The inner core is solid, as determined by the strong refraction of P waves at the inner core-outer core boundary, + and was formed by crystalizing minerals from the liquid part of the core as the Earth cools. +

    + The crust and mantle are also further distinguished by material properties into the lithosphere, asthenosphere, and mesosphere. The chemical composition is + uniform throughout the mantle though, but changes in pressure and temperature determine which polymorphs will exist at different depths. + The lithosphere contains the crust, and the upper part of the mantle down to ~100km under oceanic crust, and 200-300km under continental crust (Twiss & Moores, 2007). + The lithosphere-asthenosphere boundary is defined by the 1300K isotherm, which is the temperature where olivine starts to behave viscously. + The rocks in the mesosphere are under more pressure than those in the asthenosphere, so no longer behave viscously.

    +
    + +

    Image sourced from USGS.

    +
    +
    +
    + +{% endblock %} diff --git a/three_d_viewer/templates/three_d_viewer/rock_detail.html b/three_d_viewer/templates/three_d_viewer/rock_detail.html index ea83335..945557b 100644 --- a/three_d_viewer/templates/three_d_viewer/rock_detail.html +++ b/three_d_viewer/templates/three_d_viewer/rock_detail.html @@ -28,8 +28,9 @@ function load(){ } request.send(); } + {% endblock load %} -{% block menu_header %}Select a rock{% endblock %} +{% block menu_header %}Select a rock {% endblock %} diff --git a/three_d_viewer/templates/three_d_viewer/sample_detail.html b/three_d_viewer/templates/three_d_viewer/sample_detail.html index 70eb36c..c180f9e 100644 --- a/three_d_viewer/templates/three_d_viewer/sample_detail.html +++ b/three_d_viewer/templates/three_d_viewer/sample_detail.html @@ -403,4 +403,5 @@ function resizeCanvas() {

    + {% endblock %} \ No newline at end of file diff --git a/three_d_viewer/templates/three_d_viewer/sample_practice.html b/three_d_viewer/templates/three_d_viewer/sample_practice.html index c5bd584..806d4d0 100644 --- a/three_d_viewer/templates/three_d_viewer/sample_practice.html +++ b/three_d_viewer/templates/three_d_viewer/sample_practice.html @@ -7,7 +7,11 @@
  • {% block menu_header %}Select a sample{% endblock %}
  • diff --git a/three_d_viewer/templates/three_d_viewer/theory/bowen.html b/three_d_viewer/templates/three_d_viewer/theory/bowen.html index 483f9b5..ebdac72 100644 --- a/three_d_viewer/templates/three_d_viewer/theory/bowen.html +++ b/three_d_viewer/templates/three_d_viewer/theory/bowen.html @@ -1,4 +1,4 @@ -{% extends "three_d_viewer/base.html" %} +{% extends base_template %} {% load static %} {% block content %} diff --git a/three_d_viewer/templates/three_d_viewer/theory/pressure_temp.html b/three_d_viewer/templates/three_d_viewer/theory/pressure_temp.html index edc2d4c..c4c028d 100644 --- a/three_d_viewer/templates/three_d_viewer/theory/pressure_temp.html +++ b/three_d_viewer/templates/three_d_viewer/theory/pressure_temp.html @@ -1,4 +1,4 @@ -{% extends "three_d_viewer/base.html" %} +{% extends base_template %} {% load static %} {% block content %} diff --git a/three_d_viewer/templates/three_d_viewer/theory/structure.html b/three_d_viewer/templates/three_d_viewer/theory/structure.html index 2363fff..ed741bd 100644 --- a/three_d_viewer/templates/three_d_viewer/theory/structure.html +++ b/three_d_viewer/templates/three_d_viewer/theory/structure.html @@ -1,4 +1,4 @@ -{% extends "three_d_viewer/base.html" %} +{% extends base_template %} {% load static %} {% block content %} diff --git a/three_d_viewer/urls.py b/three_d_viewer/urls.py index 98e9a3d..7a97c6c 100644 --- a/three_d_viewer/urls.py +++ b/three_d_viewer/urls.py @@ -7,9 +7,12 @@ urlpatterns = patterns( '', url(r'^$', views.HomeView.as_view(), name='home'), url(r'^$', generic.TemplateView.as_view(template_name="three_d_viewer/home.html"), name='home'), - url(r'^theory/structure/$', generic.TemplateView.as_view(template_name="three_d_viewer/theory/structure.html"), name='theory_structure'), - url(r'^theory/bowen/$', generic.TemplateView.as_view(template_name="three_d_viewer/theory/bowen.html"), name='theory_bowen'), - url(r'^theory/pressure_temp/$', generic.TemplateView.as_view(template_name="three_d_viewer/theory/pressure_temp.html"), name='theory_pt'), + url(r'^theory/structure/$', views.TheoryTemplateView.as_view(template_name="three_d_viewer/theory/structure.html"), name='theory_structure'), + url(r'^theory/erb101_structure/$', views.ERB101TheoryTemplateView.as_view(template_name="three_d_viewer/theory/structure.html"), name='erb101_theory_structure'), + url(r'^theory/bowen/$', views.TheoryTemplateView.as_view(template_name="three_d_viewer/theory/bowen.html"), name='theory_bowen'), + url(r'^theory/erb101_bowen/$', views.ERB101TheoryTemplateView.as_view(template_name="three_d_viewer/theory/bowen.html" ), name='erb101_theory_bowen'), + url(r'^theory/pressure_temp/$', views.TheoryTemplateView.as_view(template_name="three_d_viewer/theory/pressure_temp.html"), name='theory_pt'), + url(r'^theory/erb101_pressure_temp/$', views.ERB101TheoryTemplateView.as_view(template_name="three_d_viewer/theory/pressure_temp.html"), name='erb101_theory_pt'), url(r'^minerals_practice/$', views.MineralPracticeView.as_view(template_name="three_d_viewer/minerals_practice.html"), name='minerals_practice'), url(r'^minerals/(?P\d+)/$', views.MineralDetailView.as_view(), name='mineral_detail'), url(r'^minerals_selftest/$', generic.TemplateView.as_view(template_name="three_d_viewer/minerals_selftest.html"), name='minerals_selftest'), @@ -23,6 +26,8 @@ urlpatterns = patterns( url(r'^erb101/$', generic.TemplateView.as_view(template_name="three_d_viewer/erb101/home.html"), name='erb101_home'), url(r'^erb101_rock_practice/$', views.ERB101RockPracticeView.as_view(), name='erb101_rocks_practice'), url(r'^erb101_minerals_practice/$', views.ERB101MineralPracticeView.as_view(), name='erb101_minerals_practice'), + url(r'^erb101_minerals/(?P\d+)/$', views.ERB101MineralDetailView.as_view(), name='erb101_mineral_detail'), + url(r'^erb101_rocks/(?P\d+)/$', views.ERB101RockDetailView.as_view(), name='erb101_rock_detail'), url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ) diff --git a/three_d_viewer/views.py b/three_d_viewer/views.py index e26f45f..56ba475 100644 --- a/three_d_viewer/views.py +++ b/three_d_viewer/views.py @@ -39,6 +39,7 @@ class MineralPracticeView(generic.ListView): result = chain(result, child.active_samples) context['active_samples'] = sorted(result, key=attrgetter('name')) + context['base_template'] = 'three_d_viewer/base.html' return context class MineralDetailView(generic.DetailView): @@ -61,6 +62,7 @@ class MineralDetailView(generic.DetailView): result = chain(result, child.active_samples) context['active_samples'] = sorted(result, key=attrgetter('name')) + context['base_template'] = 'three_d_viewer/base.html' return context def get_object(self, queryset=None): @@ -132,6 +134,7 @@ class FossilPracticeView(generic.ListView): result = chain(result, child.active_samples) context['active_samples'] = sorted(result, key=attrgetter('name')) + context['base_template'] = 'three_d_viewer/base.html' return context class FossilDetailView(generic.DetailView): @@ -151,6 +154,7 @@ class FossilDetailView(generic.DetailView): result = chain(result, child.active_samples) context['active_samples'] = sorted(result, key=attrgetter('name')) + context['base_template'] = 'three_d_viewer/base.html' return context def get_object(self, queryset=None): @@ -185,7 +189,7 @@ class ERB101HomeView(generic.ListView): class ERB101MineralPracticeView(generic.ListView): model = Mineral - template_name = 'three_d_viewer/minerals_practice.html' + template_name = 'three_d_viewer/erb101/minerals_practice.html' def get_context_data(self, **kwargs): context = super(ERB101MineralPracticeView, self).get_context_data(**kwargs) @@ -196,11 +200,41 @@ class ERB101MineralPracticeView(generic.ListView): result = chain(result, child.active_101_samples) context['active_samples'] = sorted(result, key=attrgetter('name')) + context['base_template'] = 'three_d_viewer/erb101/base.html' return context +class ERB101MineralDetailView(generic.DetailView): + """ + Add extra functionality for mineral details + """ + + model = Mineral + template_name = 'three_d_viewer/erb101/mineral_detail.html' + + parent_categories = Category.objects.filter(parent=None). \ + filter(active=True).order_by("name") + + def get_context_data(self, **kwargs): + context = super(ERB101MineralDetailView, 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')) + context['base_template'] = 'three_d_viewer/erb101/base.html' + return context + + def get_object(self, queryset=None): + object = super(ERB101MineralDetailView, self).get_object() + object.viewed_count += 1 + object.save() + return object + class ERB101RockPracticeView(generic.ListView): model = Sample - template_name = 'three_d_viewer/rock_practice.html' + template_name = 'three_d_viewer/erb101/rock_practice.html' parent_categories = Category.objects.filter(parent=None). \ filter(active=True).order_by("name") @@ -217,4 +251,42 @@ class ERB101RockPracticeView(generic.ListView): context['active_samples'] = sorted(result, key=attrgetter('name')) context['base_template'] = 'three_d_viewer/erb101/base.html' return context - \ No newline at end of file + + +class ERB101RockDetailView(generic.DetailView): + model = Sample + template_name = 'three_d_viewer/erb101/rock_detail.html' + + parent_categories = Category.objects.filter(parent=None). \ + filter(active=True).order_by("name") + + + def get_context_data(self, **kwargs): + context = super(ERB101RockDetailView, self).get_context_data(**kwargs) + cat = Category.objects.get(name='Rocks') + result = cat.active_samples + + for child in cat.active_children: + result = chain(result, child.active_samples) + + context['active_samples'] = sorted(result, key=attrgetter('name')) + context['base_template'] = 'three_d_viewer/erb101/base.html' + return context + + def get_object(self, queryset=None): + object = super(ERB101RockDetailView, self).get_object() + object.viewed_count += 1 + object.save() + return object + +class TheoryTemplateView(generic.TemplateView): + def get_context_data(self, **kwargs): + context = super(TheoryTemplateView, self).get_context_data(**kwargs) + context['base_template'] = 'three_d_viewer/base.html' + return context + +class ERB101TheoryTemplateView(generic.TemplateView): + def get_context_data(self, **kwargs): + context = super(ERB101TheoryTemplateView, self).get_context_data(**kwargs) + context['base_template'] = 'three_d_viewer/erb101/base.html' + return context \ No newline at end of file