Skip to content

Commit

Permalink
Merge pull request #19 from OpenGovAus/tas-parl
Browse files Browse the repository at this point in the history
Support for Tasmania's Parliament
  • Loading branch information
king-millez authored Mar 16, 2021
2 parents ad43a45 + b1c6512 commit bf31354
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 14 deletions.
Binary file added legistream/static/legistream/img/bg-tasparl.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions legistream/statuscheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}

Expand Down Expand Up @@ -88,13 +97,15 @@ 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()))
streams.append(__fed_stream(fedStream()))
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)
Expand Down
17 changes: 12 additions & 5 deletions legistream/tas.py
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 3 additions & 0 deletions legistream/templates/legistream/stream_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -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%}
Expand Down
15 changes: 6 additions & 9 deletions legistream/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit bf31354

Please sign in to comment.