Skip to content

Commit

Permalink
Merge 7766e4a into 10532e0
Browse files Browse the repository at this point in the history
  • Loading branch information
jchate6 committed Dec 30, 2023
2 parents 10532e0 + 7766e4a commit 89d9e78
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
4 changes: 4 additions & 0 deletions tom_common/static/tom_common/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background-color: black;
color: white;
}
1 change: 1 addition & 0 deletions tom_common/templates/tom_common/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<!-- Bootstrap CSS -->
{% bootstrap_css %}
<link rel="stylesheet" href="{% static 'tom_common/css/main.css' %}">
<link rel="stylesheet" href="{% static 'tom_common/css/custom.css' %}">
{% block additional_css %}
{% endblock %}
<link rel="icon" type="image/x-icon" href="{% static 'tom_common/img/favicon-32.ico' %}" sizes="32x32" />
Expand Down
37 changes: 31 additions & 6 deletions tom_setup/management/commands/tom_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.core.management.utils import get_random_secret_key
from django.utils import timezone
from django.contrib.auth.models import Group, User
# from tom_common.static.tom_common.css

BASE_DIR = settings.BASE_DIR

Expand Down Expand Up @@ -62,13 +63,24 @@ def create_project_dirs(self):
os.mkdir(os.path.join(BASE_DIR, 'templates'))
except FileExistsError:
pass
# set up custom static files
static_dir = os.path.join(BASE_DIR, 'static')
try:
os.mkdir(os.path.join(BASE_DIR, 'static'))
os.mkdir(static_dir)
except FileExistsError:
pass
# os.mknod requires superuser permissions on osx, so create a blank file instead
try:
open(os.path.join(BASE_DIR, 'static/.keep'), 'w').close()
open(os.path.join(static_dir, '.keep'), 'w').close()
except FileExistsError:
pass
common_static_dir = os.path.join(static_dir, 'tom_common')
try:
os.mkdir(common_static_dir)
except FileExistsError:
pass
try:
os.mkdir(os.path.join(common_static_dir, 'css'))
except FileExistsError:
pass
try:
Expand Down Expand Up @@ -150,14 +162,26 @@ def generate_config(self):
# TODO: Ugly hack to get project name
settings_location = os.path.join(BASE_DIR, os.path.basename(BASE_DIR), 'settings.py')
if not os.path.exists(settings_location):
msg = 'Could not determine settings.py location. Writing settings.py out to {}. Please copy file to \
the proper location after script finishes.'.format(settings_location)
msg = 'Could not determine settings.py location. Writing settings.py out to {}. Please copy file to ' \
'the proper location after script finishes.'.format(settings_location)
self.stdout.write(self.style.WARNING(msg))
with open(settings_location, 'w+') as settings_file:
settings_file.write(rendered)

self.ok()

def generate_css(self):
self.status('Generating custom.css... ')
template = get_template('tom_setup/css.tmpl')
rendered = template.render(self.context)

# TODO: Ugly hack to get project name
css_location = os.path.join(BASE_DIR, 'static', 'tom_common', 'css', 'custom.css')
with open(css_location, 'w+') as css_file:
css_file.write(rendered)

self.ok()

def generate_urls(self):
self.status('Generating urls.py... ')
template = get_template('tom_setup/urls.tmpl')
Expand All @@ -166,8 +190,8 @@ def generate_urls(self):
# TODO: Ugly hack to get project name
urls_location = os.path.join(BASE_DIR, os.path.basename(BASE_DIR), 'urls.py')
if not os.path.exists(urls_location):
msg = 'Could not determine urls.py location. Writing urls.py out to {}. Please copy file to \
the proper location after script finishes.'.format(urls_location)
msg = 'Could not determine urls.py location. Writing urls.py out to {}. Please copy file to ' \
'the proper location after script finishes.'.format(urls_location)
self.stdout.write(self.style.WARNING(msg))
with open(urls_location, 'w+') as urls_file:
urls_file.write(rendered)
Expand Down Expand Up @@ -200,6 +224,7 @@ def handle(self, *args, **options):
self.get_target_type()
self.get_hint_preference()
self.generate_config()
self.generate_css()
self.generate_urls()
self.run_migrations()
self.create_pi()
Expand Down
32 changes: 32 additions & 0 deletions tom_setup/templates/tom_setup/css.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*!
* Adapted from Bootstrap v4.6.2 (https://getbootstrap.com/)
* Set defaults for custom css
*/
:root {
--primary: #007bff;
--secondary: #6c757d;
--success: #28a745;
--info: #17a2b8;
--warning: #ffc107;
--danger: #dc3545;
--light: #f8f9fa;
--dark: #343a40;
}

body {
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
background-color: #fff
}

a {
color: #007bff;
background-color: transparent
}

a:hover {
color: #0056b3;
text-decoration: underline
}
2 changes: 1 addition & 1 deletion tom_targets/templates/tom_targets/target_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{% load comments bootstrap4 tom_common_extras targets_extras observation_extras dataproduct_extras static cache %}
{% block title %}Target {{ object.name }}{% endblock %}
{% block additional_css %}
<link rel="stylesheet" href="{% static 'tom_common/css/main.css' %}">
<link rel="stylesheet" href="{% static 'tom_targets/css/main.css' %}">
<link rel="stylesheet" href="{% static 'tom_targets/css/custom.css' %}">
{% endblock %}
{% block content %}
<script>
Expand Down

0 comments on commit 89d9e78

Please sign in to comment.