Skip to content

Conversation

@lanjelot
Copy link
Collaborator

Sorry I couldn't break this up into 2 PRs. Two new improvements:

  • the "Quick Add CTF" snippet now simply redirects to /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.
  • the Import from CTFTime page now also lists the currently running CTFs

…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.
Copy link
Owner

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.

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}",
Copy link
Owner

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 ""
Copy link
Owner

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

Copy link
Collaborator Author

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.

Copy link
Owner

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)

CTFTIME_URL = "https://ctftime.org"
CTFPAD_DEFAULT_CTF_LOGO = "blank-ctf.png"
CTPAD_ACCEPTED_IMAGE_EXTENSIONS = (".png", ".jpg", ".gif", ".bmp")
CTFPAD_ACCEPTED_IMAGE_EXTENSIONS = (".png", ".jpg", ".gif", ".bmp")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍

@hugsy hugsy merged commit dea73b4 into hugsy:master Nov 22, 2020
@lanjelot lanjelot deleted the improve-quickadd branch November 22, 2020 18:17
@hugsy hugsy added this to the 0.1 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants