diff --git a/setup.py b/setup.py index 5e6fce8..972ca0d 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ }, description="This is submit50, with which you can submit solutions to problems for CS50.", long_description="This is submit50, with which you can submit solutions to problems for CS50.", - install_requires=["lib50>=3,<4", "packaging", "requests>=2.19", "setuptools", "termcolor>=1.1"], + install_requires=["lib50>=3,<4", "packaging", "pytz", "requests>=2.19", "setuptools", "termcolor>=1.1"], keywords=["submit", "submit50"], name="submit50", python_requires=">=3.6", @@ -26,6 +26,6 @@ entry_points={ "console_scripts": ["submit50=submit50.__main__:main"] }, - version="3.1.5", + version="3.2.0", include_package_data=True ) diff --git a/submit50/__main__.py b/submit50/__main__.py index d1538ce..51e1a6a 100755 --- a/submit50/__main__.py +++ b/submit50/__main__.py @@ -16,6 +16,8 @@ from importlib.resources import files from packaging import version +from datetime import datetime +from pytz import timezone from . import __version__, CONFIG_LOADER # Internationalization @@ -137,7 +139,7 @@ def prompt(honesty, included, excluded): # Show default message if honesty == True: honesty_question = _( - "Keeping in mind the course's policy on academic honesty, " + "Keeping in mind the course's policy on academic honesty, including its restrictions on AI use, " "are you sure you want to submit these files (yes/no)? " ) # If a custom message is configured, show that instead @@ -162,6 +164,26 @@ def prompt(honesty, included, excluded): return True +def check_slug_year(slug): + """Warn if the slug is for previous year's CS50x course.""" + + # extract the year from the slug + try: + year = re.search(r"cs50/problems/(\d{4})/x", slug) + if year and int(year.group(1)) < int(datetime.now(timezone("US/Eastern")).year): + suggested_slug = re.sub(r"cs50/problems/\d{4}/x", f"cs50/problems/{datetime.now(timezone('US/Eastern')).year}/x", slug) + cprint(_("You are submitting to a previous year's CS50x course. Your submission will not be counted towards this year's course."), "yellow") + cprint(_("If you are looking to submit to this year's course, please use the following slug:"), "yellow") + cprint(suggested_slug, "yellow") + + # Ask if they want to continue + if not re.match(f"^\s*(?:{_('y|yes')})\s*$", input(_("Do you want to continue with this submission (yes/no)? ")), re.I): + raise Error(_("User aborted submission.")) + + except ValueError: + pass + + def excepthook(type, value, tb): """Report an exception.""" if (issubclass(type, Error) or issubclass(type, lib50.Error)) and str(value): @@ -223,7 +245,8 @@ def main(): check_announcements() check_version() - + check_slug_year(args.slug) + user_name, commit_hash, message = lib50.push("submit50", args.slug, CONFIG_LOADER, prompt=prompt) print(message) diff --git a/submit50/locale/es/LC_MESSAGES/submit50.po b/submit50/locale/es/LC_MESSAGES/submit50.po index 6711cb5..5e4e587 100644 --- a/submit50/locale/es/LC_MESSAGES/submit50.po +++ b/submit50/locale/es/LC_MESSAGES/submit50.po @@ -15,11 +15,11 @@ msgid "Sorry, something's wrong! Let sysadmins@cs50.harvard.edu know!" msgstr "¡Lo siento, algo está mal! ¡Déjale saber a sysadmins@cs50.harvard.edu!" msgid "" -"Keeping in mind the course's policy on academic honesty, are you sure you " -"want to submit these files (yes/no)? " +"Keeping in mind the course's policy on academic honesty, including its restrictions on AI use, " +"are you sure you want to submit these files (yes/no)? " msgstr "" -"Teniendo en cuenta la política de honestidad académica del curso, ¿estás " -"seguro que quieres enviar estos archivos (sí/no)? " +"Teniendo en cuenta la política de honestidad académica del curso, incluidas sus restricciones sobre el uso de IA, " +"¿estás seguro que quieres enviar estos archivos (sí/no)? " msgid "y|yes" msgstr "s|s[ií]"