Skip to content

Commit

Permalink
Don't use old requires in Reddit/templates
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-uva committed Jan 18, 2024
1 parent c5fbe02 commit 63fce56
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 20 additions & 2 deletions datasources/reddit/search_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class SearchReddit(Search):
"type": UserInput.OPTION_INFO,
"help": "The requirement for searching by keyword has been lifted for your account; you can search by "
"date range only. This can potentially return hundreds of millions of posts, so **please be "
"careful** when using this privilege.",
"requires": "reddit-search.can_query_without_keyword"
"careful** when using this privilege."
},
"pushshift_track": {
"type": UserInput.OPTION_CHOICE,
Expand Down Expand Up @@ -127,6 +126,25 @@ class SearchReddit(Search):
since = "since"
after = "after"

@classmethod
def get_options(cls, parent_dataset=None, user=None):
"""
Determine if user needs to see the 'careful with wildcard queries!'
warning
:param parent_dataset:
:param user:
:return dict: Options definition
"""
options = cls.options

# this warning isn't needed if the user can't search for everything
# anyway
if not config.get("reddit-search.can_query_without_keyword"):
del options["wildcard-warning"]

return options

@staticmethod
def build_query(query):
"""
Expand Down
2 changes: 0 additions & 2 deletions webtool/templates/components/create-dataset-option.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
{% endif %}
{% for option in options %}
{% set settings = options[option] %}
{% if not settings.requires or (current_user.is_authenticated and current_user.is_admin) or current_user.get_attribute(settings.requires) %}
{% if not fieldset.open %}<fieldset>{% set fieldset.open = True %}{% endif %}
{% include 'components/datasource-option.html' %}
{% endif %}
{% endfor %}
{% if fieldset_open %}
</fieldset>
Expand Down

0 comments on commit 63fce56

Please sign in to comment.