diff --git a/legistream/static/legistream/img/bg-tasparl.webp b/legistream/static/legistream/img/bg-tasparl.webp new file mode 100644 index 0000000..dfe2feb Binary files /dev/null and b/legistream/static/legistream/img/bg-tasparl.webp differ diff --git a/legistream/static/legistream/img/thumbs/tas_hoa.webp b/legistream/static/legistream/img/thumbs/tas_hoa.webp new file mode 100644 index 0000000..923109d Binary files /dev/null and b/legistream/static/legistream/img/thumbs/tas_hoa.webp differ diff --git a/legistream/static/legistream/img/thumbs/tas_lc.webp b/legistream/static/legistream/img/thumbs/tas_lc.webp new file mode 100644 index 0000000..f34ed5e Binary files /dev/null and b/legistream/static/legistream/img/thumbs/tas_lc.webp differ diff --git a/legistream/statuscheck.py b/legistream/statuscheck.py index 045a039..e925ae0 100644 --- a/legistream/statuscheck.py +++ b/legistream/statuscheck.py @@ -61,6 +61,15 @@ def __nsw_stream(stream_object): data_dict[STREAM_STAT] = False return data_dict +def __tas_stream(stream_object): + data_dict = {PARL_ID: 'Tasmania', 'lower_stat': stream_object.lower_is_live, 'upper_stat': stream_object.upper_is_live} + data_dict[URL] = '/tas' + if(data_dict['lower_stat'] or data_dict['upper_stat']): + data_dict[STREAM_STAT] = True + else: + data_dict[STREAM_STAT] = False + return data_dict + def __vic_stream(stream_object): data_dict = {PARL_ID: 'Victoria', URL: '/vic'} @@ -88,6 +97,7 @@ def write_parl_stats(): from legistream_backend.nsw import Stream as nswStream from legistream_backend.nt import Stream as ntStream from legistream_backend.qld import Stream as qldStream + from legistream_backend.tas import Stream as tasStream from legistream_backend.vic import Stream as vicStream from legistream_backend.wa import Stream as waStream streams.append(__act_stream(actStream())) @@ -95,6 +105,7 @@ def write_parl_stats(): streams.append(__nsw_stream(nswStream())) streams.append(__nt_stream(ntStream())) streams.append(__qld_stream(qldStream())) + streams.append(__tas_stream(tasStream())) streams.append(__vic_stream(vicStream())) streams.append(__wa_stream(waStream())) return(streams) diff --git a/legistream/tas.py b/legistream/tas.py index 937a4e9..502285e 100644 --- a/legistream/tas.py +++ b/legistream/tas.py @@ -1,12 +1,19 @@ +import os, json from legistream_backend.tas import Stream as tasStream tas_stream = tasStream() +try: + with open(os.path.dirname(os.path.realpath(__file__)) + '/statuses/stream_stats.json', 'r') as f: + _from_json = json.loads(f.read())[1][-3] +except: + with open(os.path.dirname(os.path.realpath(__file__)) + '/statuses/placeholder.json', 'r') as f: + _from_json = json.loads(f.read())[1][-3] tas_urls = [] -if(tas_stream.lower_is_live): - tas_urls.append({'url': tas_stream.lower_stream_url, 'title': 'House of Assembly', 'safe': 'house-assembly-vid'}) -if(tas_stream.upper_is_live): - tas_urls.append({'url': tas_stream.upper_stream_url, 'title': 'Legislative Council', 'safe': 'legislative-council-vid'}) - +if(_from_json['lower_stat']): + tas_urls.append({'url': tas_stream.lower_stream_url, 'title': 'House of Assembly', 'safe': 'house-assembly-vid', 'thumb': 'legistream/img/thumbs/tas_hoa.webp'}) +'''if(_from_json['upper_stat']): + tas_urls.append({'url': tas_stream.upper_stream_url, 'title': 'Legislative Council', 'safe': 'legislative-council-vid', 'thumb': 'legistream/img/thumbs/tas_lc.webp'}) +''' parl_title = 'Tasmania' \ No newline at end of file diff --git a/legistream/templates/legistream/stream_page.html b/legistream/templates/legistream/stream_page.html index f9a531a..29947cf 100644 --- a/legistream/templates/legistream/stream_page.html +++ b/legistream/templates/legistream/stream_page.html @@ -38,6 +38,9 @@ {% if title == 'Victoria Parliament' %} background-image: url('{% static 'legistream/img/bg-vicparl.webp' %}') {% endif %} + {% if title == 'Tasmania Parliament' %} + background-image: url('{% static 'legistream/img/bg-tasparl.webp' %}') + {% endif %} {% if title == 'demoparl' %} background-image: url('{% static 'legistream/img/bg-demoparl.webp' %}'); {%endif%} diff --git a/legistream/views.py b/legistream/views.py index dc584bf..c9a4317 100644 --- a/legistream/views.py +++ b/legistream/views.py @@ -92,16 +92,13 @@ def sa(request): return(render(request, 'legistream/vic_tas.html', context=context)) def tas(request): - #from . import tas - #context = { - # 'stream_urls': tas.tas_urls, - # 'parl': tas.parl_title, - # 'title': 'Tasmania' - #} - - context = {} + from . import tas + context = gen_context() + context['stream_urls'] = tas.tas_urls + context['parl'] = tas.parl_title + context['title'] = 'Tasmania Parliament' - return(render(request, 'legistream/vic_tas.html', context=context)) + return(render(request, 'legistream/stream_page.html', context=context)) def vic(request): from . import vic diff --git a/requirements.txt b/requirements.txt index 0c30e73..3321d9a 100644 Binary files a/requirements.txt and b/requirements.txt differ