Skip to content

Commit

Permalink
Fix botched merge
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-uva committed Feb 4, 2022
1 parent d6549f1 commit 2dcd490
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion datasources/fourchan/search_4chan-actual.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def validate_query(query, request, user):
"""

# this is the bare minimum, else we can't narrow down the full data set
if not user.is_admin() and not user.get_value("4chan.can_query_without_keyword", False) and not query.get("body_match", None) and not query.get("subject_match", None) and query.get("search_scope", "") != "random-sample":
if not user.is_admin and not user.get_value("4chan.can_query_without_keyword", False) and not query.get("body_match", None) and not query.get("subject_match", None) and query.get("search_scope", "") != "random-sample":
raise QueryParametersException("Please provide a message or subject search query")

query["min_date"], query["max_date"] = query["daterange"]
Expand Down
2 changes: 1 addition & 1 deletion datasources/fourchan/search_4chan.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def validate_query(query, request, user):
"""

# this is the bare minimum, else we can't narrow down the full data set
if not user.is_admin() and not user.get_value("4chan.can_query_without_keyword", False) and not query.get("body_match", None) and not query.get("subject_match", None) and query.get("search_scope", "") != "random-sample":
if not user.is_admin and not user.get_value("4chan.can_query_without_keyword", False) and not query.get("body_match", None) and not query.get("subject_match", None) and query.get("search_scope", "") != "random-sample":
raise QueryParametersException("Please provide a message or subject search query")

query["min_date"], query["max_date"] = query["daterange"]
Expand Down
2 changes: 1 addition & 1 deletion datasources/reddit/search_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def validate_query(query, request, user):
query["board"] = ",".join(boards)

# this is the bare minimum, else we can't narrow down the full data set
if not user.is_admin() and not user.get_value("reddit.can_query_without_keyword", False) and not query.get("body_match", "").strip() and not query.get("subject_match", "").strip() and not query.get("subject_url", ""):
if not user.is_admin and not user.get_value("reddit.can_query_without_keyword", False) and not query.get("body_match", "").strip() and not query.get("subject_match", "").strip() and not query.get("subject_url", ""):
raise QueryParametersException("Please provide a body query or subject query.")

# body query and full threads are incompatible, returning too many posts
Expand Down
2 changes: 1 addition & 1 deletion datasources/usenet/search_usenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def validate_query(query, request, user):
"""

# this is the bare minimum, else we can't narrow down the full data set
if not user.is_admin() and not user.get_value("usenet.can_query_without_keyword", False) and not query.get("body_match", None) and not query.get("subject_match", None) and query.get("search_scope", "") != "random-sample":
if not user.is_admin and not user.get_value("usenet.can_query_without_keyword", False) and not query.get("body_match", None) and not query.get("subject_match", None) and query.get("search_scope", "") != "random-sample":
raise QueryParametersException("Please provide a body query, subject query or random sample size.")

# the dates need to make sense as a range to search within
Expand Down
8 changes: 8 additions & 0 deletions helper-scripts/migrate/migrate-1.24-1.25.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,13 @@
else:
print(" ...Yes, nothing to update.")

print(" Checking if anonymous user exists...")
has_anon = db.fetchone("SELECT COUNT(*) AS num FROM users WHERE name = 'anonymous'")
if not has_anon["num"] > 0:
print(" ...No, adding.")
db.execute("INSERT INTO users (name, password) VALUES ('anonymous', '')")
db.commit()



print(" Done!")
5 changes: 2 additions & 3 deletions webtool/lib/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def can_access_dataset(self, dataset):
if not dataset.is_private:
return True

elif self.is_admin():
elif self.is_admin:
return True

elif self.get_id() == dataset.owner:
Expand All @@ -113,8 +113,7 @@ def can_access_dataset(self, dataset):
else:
return False


def __init__(self, data, authenticated=False):
def __init__(self, db, data, authenticated=False):
"""
Instantiate user object
Expand Down
2 changes: 1 addition & 1 deletion webtool/templates/result-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 class="blocktitle">
<li><a href="{{ url_for('explorer_dataset', key=dataset.key) }}" class="explorer-dataset" target="__blank"><i class="fas fa-binoculars" aria-hidden="true"></i> Explore & annotate</a></li>
{% endif %}
<li><a href="{{ url_for('toggle_favourite_interactive', key=dataset.key) }}" class="toggle-favourites"><i class="fa{% if is_favourite %}r{% else %}s{% endif %} fa-star" aria-hidden="true"></i> {% if is_favourite %}Delete from{% else %}Add to{% endif %} favourites</a></li>
{% if current_user.is_authenticated and (current_user.is_admin() or current_user.get_id() == dataset.owner) %}
{% if current_user.is_authenticated and (current_user.is_admin or current_user.get_id() == dataset.owner) %}
<li><a href="{{ url_for('toggle_private_interactive', key=dataset.key) }}" class="toggle-private"><i class="fas fa-lock{% if dataset.is_private %}-open{% endif %}" aria-hidden="true"></i> {% if dataset.is_private %}Make public{% else %}Make private{% endif %}</a></li>
{% endif %}
<li><a href="{{ url_for('show_result', key=dataset.key) }}"><i class="fas fa-link" aria-hidden="true"></i> Permalink</a></li>
Expand Down
10 changes: 5 additions & 5 deletions webtool/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def get_mapped_result(key):
except TypeError:
abort(404)

if dataset.is_private and not (current_user.is_admin() or dataset.owner == current_user.get_id()):
if dataset.is_private and not (current_user.is_admin or dataset.owner == current_user.get_id()):
return error(403, error="This dataset is private.")

if dataset.get_extension() == ".csv":
Expand Down Expand Up @@ -350,7 +350,7 @@ def show_results(page):
where.append("query LIKE %s")
replacements.append("%" + query_filter + "%")

if not current_user.is_admin():
if not current_user.is_admin:
where.append("(is_private = FALSE OR owner = %s)")
replacements.append(current_user.get_id())

Expand Down Expand Up @@ -450,7 +450,7 @@ def preview_items(key):
except TypeError:
return error(404, error="Dataset not found.")

if dataset.is_private and not (current_user.is_admin() or dataset.owner == current_user.get_id()):
if dataset.is_private and not (current_user.is_admin or dataset.owner == current_user.get_id()):
return error(403, error="This dataset is private.")

preview_size = 1000
Expand Down Expand Up @@ -570,10 +570,10 @@ def restart_dataset(key):
except TypeError:
return error(404, message="Dataset not found.")

if dataset.is_private and not (current_user.is_admin() or dataset.owner == current_user.get_id()):
if dataset.is_private and not (current_user.is_admin or dataset.owner == current_user.get_id()):
return error(403, error="This dataset is private.")

if current_user.get_id() != dataset.owner and not current_user.is_admin():
if current_user.get_id() != dataset.owner and not current_user.is_admin:
return error(403, message="Not allowed.")

if not dataset.is_finished():
Expand Down

0 comments on commit 2dcd490

Please sign in to comment.