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

introducing variables that change the content depending on the select… #191

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Empty file.
9 changes: 9 additions & 0 deletions bhtom2/bhtom_mymodule/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path
from . import views

app_name = 'bhtom_mymodule'

urlpatterns = [
path('list/', views.mymodule_list, name='list'),
path('details/', views.mymodule_details, name='details'),
]
7 changes: 7 additions & 0 deletions bhtom2/bhtom_mymodule/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.shortcuts import render

def mymodule_list(request):
return render(request, 'bhtom_mymodule/list.html')

def mymodule_details(request):
return render(request, 'bhtom_mymodule/details.html')
Binary file added bhtom2/static/oca_tom_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions bhtom2/templates/bhtom_common/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

{% bootstrap_javascript jquery='True' %}

<title>BHTOM | {% block title %}{% endblock %}</title>
<title>{{ logo_text }} | {% block title %}{% endblock %}</title> <!-- Dynamiczny tytuł -->
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="/"><img src="{% static 'logo.png' %}" class="img-fluid"> BHTOM</a>
<a class="navbar-brand" href="/"><img src="{% static 'logo.png' %}" class="img-fluid"> {{ logo_text }}</a> <!-- Dynamiczny tekst logo -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
Expand Down Expand Up @@ -58,7 +58,7 @@
{% navbar_login %}
</ul>
</div>

</nav>

{% if PROFILE != 'PROD' %}
Expand All @@ -83,4 +83,3 @@
{% endblock %}
</body>
</html>

21 changes: 12 additions & 9 deletions bhtom2/templates/bhtom_common/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
{% block content %}
<div class="row">
<div class="col-lg-9">
<h2 class="text-center">Black Hole TOM 2.0</h2>
<p class="text-center"><img
src="{% static 'bh_tom_image.jpg' %}"
class="img-fluid mx-auto"></p>
<h2 class="text-center">{{ title_text }}</h2>
<p class="text-center"><img src="{% static wallpaper %}" class="img-fluid mx-auto"></p>
<p class="text-center">(Image courtesy of NASA/ESA/Gaia/DPAC)</p>
<div>
<div id="react">
Expand All @@ -16,12 +14,17 @@ <h2 class="text-center">Black Hole TOM 2.0</h2>
<i class="pending"></i><br><br>
</div>
</div>
{% if title_text == "Black Hole TOM 2.0" %}
<h3 style="color: red;">New version of BHTOM is still in beta-testing</h3>
<p><a href="https://github.com/BHTOM-Team/bhtom2/blob/bhtom2-dev/Documentation/Documentation.md">Draft version of the documentation</a></p>
<ul>
<li>Some features might not work</li>
<li>Report to us in case of problems</li>
</ul>
{% elif title_text == "OCA TOM" %}
<h3 style="color: blue;">OCM Observatory proposals, targets and observations database</h3>
<p>Here you can find various astronomical data and tools specific to the OCA TOM project.</p>
majkelx marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
</div>
<div class="col-lg-3">
<div class="card text-white bg-dark">
Expand All @@ -42,18 +45,18 @@ <h3 style="color: red;">New version of BHTOM is still in beta-testing</h3>

<h6>
<i> "I have one request, which is this, that the observations shall be made known each year. Observations buried in a desk are no observations. Should they be entrusted to me for reduction, or even for publication, I will undertake it with joy and thanks, and will also answer all questions with care and with the greatest pleasure.”
</i>
</i>
<br>
<p style="text-align:right;">
Friedrich Wilhelm August Argelander, 1844 <br>
“An Appeal to the Friends of Astronomy” in Schumacher's Astronomical Year Book<br>
translated by Annie Jump Cannon, Popular Astronomy, 1912
</p>
</h6>
<!--- from https://cosmoquest.org/x/365daysofastronomy/2010/01/24/january-24th-friedrich-wilhelm-august-argelander/-->
</p>
</h6>
<!--- from https://cosmoquest.org/x/365daysofastronomy/2010/01/24/january-24th-friedrich-wilhelm-august-argelander/-->
<script>
{#window.props = {{props|json}}; // make sure to escape your props to prevent XSS! See here for the source for the json filter: https://gist.github.com/pirate/c18bfe4fd96008ffa0aef25001a2e88f#}
window.react_mount = document.getElementById('react');
</script>

{% endblock %}
{% endblock %}
15 changes: 15 additions & 0 deletions bhtom2/templates/bhtom_common/navbar_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,19 @@
</div>
</li>

{% endif %}

{% if customization == "OCATOM" %}
{% if request.user.is_superuser or request.user.is_staff %}
<li class="nav-item dropdown {% if 'mymodule' in request.resolver_match.url_name %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
MyModule {{ customization }}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{% url 'bhtom_mymodule:list' %}">List</a>
<a class="dropdown-item" href="{% url 'bhtom_mymodule:details' %}">Details</a>
</div>
</li>
{% endif %}
{% endif %}
2 changes: 2 additions & 0 deletions bhtom2/templates/bhtom_mymodule/details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>MyModule Details</h1>
<p>To jest strona szczegółów dla MyModule.</p>
2 changes: 2 additions & 0 deletions bhtom2/templates/bhtom_mymodule/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>MyModule List</h1>
<p>To jest strona listy dla MyModule.</p>
1 change: 1 addition & 0 deletions bhtom2/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
name='alerts:list'),
path('', include('django_prometheus.urls')),
path('metrics/', custom_metrics, name='custom_metrics'),
path('mymodule/', include('bhtom2.bhtom_mymodule.urls', namespace='bhtom_mymodule')),

] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

2 changes: 1 addition & 1 deletion bhtom_base
8 changes: 4 additions & 4 deletions docker/dev/dev_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fi

echo "Collecting static..."

while ! python manage.py collectstatic --no-input 2>&1; do
echo "Collecting static..."
sleep 3
done
#while ! python manage.py collectstatic --no-input 2>&1; do
Copy link

Choose a reason for hiding this comment

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

collectstatic, zależnie od serwera na którym uruchamiany jest projekt, może kopiować statyczne pliki tak żeby nie były serwowane przez pythona tylko bezpośrednio. (wźcej poszukaj info o django collectstatic)

Nie wiem jak chłopaki to u siebie organizują w dev, ale też nie wywalałbym im tego bez porozumienia - jak Ci to sprawiało problemy to ich zapytaj.

ewentualnie cały katalog docker/dev można skopiować na docker/oca_dev i tam hulaj dusza, ale i tak trzeba zromieć zarządanie staticami przez django generalnie (z doc) i w kontekście bhtoma (od chłopaków)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nie kopiujemy static, używamy ścieżki w której one są, udostępniamy je przez nginx location i alias. Co do drugiej sprawy, może faktycznie lepiej by było docker/oca_dev, bo trudno powiedzieć, w którym kierunku będą szły nasze zmiany w przyszłości - ale nie upieram się.

# echo "Collecting static..."
# sleep 3
#done

echo "Migrating..."

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ djangorestframework>=3.12
django-pgviews==0.5.7
django-tables2==2.4.1
factory_boy==3.2.1
fits2image==0.4.4
Copy link

Choose a reason for hiding this comment

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

O ile nie potrzebujesz podnosić wersji zależności, nie mieszalbym tego tutaj.
Jeśli nie ma bezpośredniego powodu przywróciłbym oryginalne requirements.txt

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nie mogłem odpalić projektu lokalnie bez podnoszenia wersji

fits2image==0.4.6
graypy==2.1.0
importlib-metadata==4.11.3
Markdown==3.3.4
Markdown==3.4.1
mechanize==0.4.8
pandas==1.4.2
pyfakefs==4.5.6
Expand All @@ -36,7 +36,7 @@ pillow==9.0.1
plotly>=5.7.0
pylatex==1.4.1
recommonmark>=0.7
specutils==1.5.0
specutils==1.7.0
sphinx>=4.0
lxml==4.9.1
crispy-bootstrap4>=2022.1
Expand Down
2 changes: 2 additions & 0 deletions settings/.bhtom.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ POSTGRES_PORT=5430
KAFKA_HOST_PORT=localhost:9092

############################## APLICATION #########################################
CUSTOMIZATION=BHTOM
#CUSTOMIZATION=OCATOM

#aplication
ALLOWED_HOSTS=localhost,0.0.0.0,127.0.0.1,host.docker.internal
Expand Down
13 changes: 12 additions & 1 deletion settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
'crispy_bootstrap4',
'drf_yasg',
'django_guid',
'django_prometheus'
'django_prometheus',
'bhtom2.bhtom_mymodule',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -495,3 +496,13 @@ def generate_name_tuple(data_source: DataSource) -> tuple:

DATA_UPLOAD_MAX_MEMORY_SIZE = 52428800 # 50 MB (adjust as needed)

CUSTOMIZATION = secret.get("CUSTOMIZATION", 'BHTOM')

if CUSTOMIZATION == "OCATOM":
CUST_WALLPAPER = 'oca_tom_image.jpg'
TITLE_TEXT = "OCA TOM"
LOGO_TEXT = "OCATOM"
else: # CUSTOMIZATION == "BHTOM"
CUST_WALLPAPER = 'bh_tom_image.jpg'
TITLE_TEXT = "Black Hole TOM 2.0"
LOGO_TEXT = "BHTOM"