-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use CTFTime URL to pull CTF info and include the currently running CTFs to the Import listing #6
Conversation
…rt page now shows the currently running CTFs
def ctftime_fetch_next_ctf_data() -> list: | ||
"""Retrieve the next CTFs from CTFTime API | ||
def ctftime_fetch_running_ctf_data() -> list: | ||
"""Retrieve the currently running CTFs from CTFTime API. I couldn't do this by only using the CTFTime API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouais ya pas d'API pour ca sur CTFTime, c'est chiant, j'utilise le meme trick pour les commandes dans metabot
.
Tu peux virer le comment ? Il apporte rien a la description de la function et le nom de la function explique suffisemment bien ce que ca fait.
ctfpad/helpers.py
Outdated
""" | ||
try: | ||
res = requests.get(CTFTIME_API_EVENTS_URL, headers={"user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0"}) | ||
# retrieve CTFs that are supposed to start and finish within a 14-day window | ||
res = requests.get(f"{CTFTIME_API_EVENTS_URL}?limit=100&start={time()-(3600*24*7):.0f}&finish={time()+(3600*24*7):.0f}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu peux foutre le limit=100
en param par default a la function? ca sera ptet utile dans le future
form = self.form_class(initial=self.initial) | ||
initial = {} | ||
initial["name"] = request.GET.get("name") or "" | ||
initial["url"] = request.GET.get("url") or "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu peux m'expliquer pourquoi tu passes pas juste ctftime_id
comme GET argument, au lieu de l'url ctftime en entier? Comme ca tu laisses la vue faire le call a l'api ctftime, ca fait un code plus clean et pas besoin d'utiliser des re
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c'est pour que le gens puissent passer des URLs CTFTime dans le Quick Add snippet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est une mauvaise idee je pense, pcq ca sera utilise apres pour le champ URL qui est suppose etre la pour pointer vers l'URL du ctf, pas ctftime.
Dans ce cas, le mieux est de virer le HTML input url
et le remplacer par ctftime_id (opt)
CTFPAD_ACCEPTED_IMAGE_EXTENSIONS = (".png", ".jpg", ".gif", ".bmp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch 👍
Sorry I couldn't break this up into 2 PRs. Two new improvements:
/ctfs/import?url=..&name=..
, the Import view will pull all the info from the CTFTime API if the user provided a CTFTime URL otherwise the values are pre-filled into the CTF Create page as-is.Import from CTFTime
page now also lists the currently running CTFs