Skip to content

Commit

Permalink
add ISP report screenshot openrightsgroup/Blocking-Middleware#115
Browse files Browse the repository at this point in the history
  • Loading branch information
dantheta committed Aug 8, 2021
1 parent eb0e7b5 commit a9b3ef6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion BlockedFrontend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)

from NORM import DBObject,Query
from NORM import DBObject, Query
from NORM.exceptions import ObjectNotFound


Expand Down Expand Up @@ -496,6 +496,17 @@ def get_report_categories(self, category_type):
yield UrlReportCategory(self.conn, data=row)
q.close()

def get_screenshot_url(self):
return "https://www.blocked.org.uk/screenshots/{0}.png".format(self['hash'])

def get_screenshot_date(self):
try:
import requests
req = requests.head(self.get_screenshot_url())
return req.headers['Last-Modified']
except:
return None


class Category(DBObject):
TABLE = 'public.categories'
Expand Down
4 changes: 4 additions & 0 deletions BlockedFrontend/templates/admin/ispreports_email.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ <h3>Site details</h3>
<a target="_blank" href="{{ url }}" class="btn btn-link" title="View reported website; opens in a new window">View {{ url|domain }} <span class="glyphicon glyphicon-share"></span></a>
</div>

<div>
<img src="{{ urlobj.get_screenshot_url() }}" class="img-responsive" title="{{ url }} screenshot {{ urlobj.get_screenshot_date() }}"/>
</div>

</div>

<div class="col-md-2" style="text-align: right">
Expand Down

0 comments on commit a9b3ef6

Please sign in to comment.