Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/breatheco-de/apiv2
Browse files Browse the repository at this point in the history
  • Loading branch information
alesanchezr committed Dec 9, 2024
2 parents 499f71f + e795640 commit fdf3f04
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class Command(BaseCommand):
help = "Clean data from marketing module"
github_url_pattern = re.compile(r"https?:\/\/github\.com\/(?P<user>[^\/]+)\/(?P<repo>[^\/\s]+)\/?")
github_url_pattern = re.compile(r"https?://github\.com/(?P<user>[^/\s]+)/(?P<repo>[^/\s]+)/?")

def handle(self, *args, **options):
self.fill_whitelist()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.1.4 on 2024-12-09 20:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("assignments", "0020_alter_userattachment_mime"),
]

operations = [
migrations.AlterField(
model_name="repositorydeletionorder",
name="repository_name",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="repositorydeletionorder",
name="repository_user",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="repositorywhitelist",
name="repository_name",
field=models.CharField(max_length=256),
),
migrations.AlterField(
model_name="repositorywhitelist",
name="repository_user",
field=models.CharField(max_length=256),
),
]
8 changes: 4 additions & 4 deletions breathecode/assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def __init__(self, *args, **kwargs):
status = models.CharField(max_length=15, choices=Status, default=Status.PENDING)
status_text = models.TextField(default=None, null=True, blank=True)

repository_user = models.CharField(max_length=100)
repository_name = models.CharField(max_length=100)
repository_user = models.CharField(max_length=256)
repository_name = models.CharField(max_length=256)

starts_transferring_at = models.DateTimeField(default=None, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
Expand All @@ -296,8 +296,8 @@ class RepositoryWhiteList(models.Model):
Provider = Provider

provider = models.CharField(max_length=15, choices=Provider, default=Provider.GITHUB)
repository_user = models.CharField(max_length=100)
repository_name = models.CharField(max_length=100)
repository_user = models.CharField(max_length=256)
repository_name = models.CharField(max_length=256)

created_at = models.DateTimeField(auto_now_add=True, editable=False)

Expand Down
38 changes: 21 additions & 17 deletions breathecode/registry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ def async_pull_project_dependencies(asset_slug):

target_asset = asset
if asset.template_url is not None and asset.template_url != "":
target_asset = Asset.get_by_github_url(asset.template_url)

# To avoid legacy issues we have to mark assets.template_url as "self" when no template is needed
if asset.template_url == "self":
target_asset = asset
else:
target_asset = Asset.get_by_github_url(asset.template_url)

if target_asset is None:
raise Exception(
f"Asset {asset_slug} template {asset.template_url} not found in the database as another asset"
Expand Down Expand Up @@ -614,47 +620,45 @@ def async_build_asset_context(asset_id):
lang = asset.lang or asset.category.lang
lang_name = LANG_MAP.get(lang, lang)

context = f"This {asset.asset_type} about {asset.title} is written in {lang_name}. "
context = f"This {asset.asset_type} called '{asset.title}' is written in {lang_name}. "

translations = ", ".join([x.title for x in asset.all_translations.all()])
if translations:
context = context[:-2]
context += f", and it has the following translations: {translations}. "
context += f"It has the following translation languages: {translations}. "

if asset.solution_url:
context = context[:-2]
context += f", and it has a solution code this link is: {asset.solution_url}. "
context += f"It has a solution published on this link: {asset.solution_url}. "

if asset.solution_video_url:
context = context[:-2]
context += f", and it has a video solution this link is {asset.solution_video_url}. "

context += f"It's category related is (what type of skills the student will get) {asset.category.title}. "
context += f"It also has a video solution, published on this link is {asset.solution_video_url}. "

technologies = ", ".join([x.title for x in asset.technologies.filter(Q(lang=lang) | Q(lang=None))])
if technologies:
context += f"This asset is about the following technologies: {technologies}. "
context += f"This {asset.asset_type} is about the following technologies: {technologies}. "

if asset.external:
context += "This asset is external, which means it opens outside 4geeks. "
context += f"This {asset.asset_type} opens outside of 4Geeks.com. "

if asset.interactive:
context += "This asset opens on LearnPack so it has a step-by-step of the exercises that you should follow. "
context += f"This {asset.asset_type} uses LearnPack with an interactive step-by-step tutorial the student must follow. "

if asset.gitpod:
context += (
f"This {asset.asset_type} can be opened both locally or with click and code (This "
"way you don't have to install anything and it will open automatically on gitpod or github codespaces). "
f"This {asset.asset_type} can be opened both locally on your computer or in the cloud using our 'click and learn' technology (This "
"way you don't have to install anything, and it will open automatically in the cloud). "
)

if asset.interactive == True and asset.with_video == True:
context += f"This {asset.asset_type} has videos on each step. "
context += f"This {asset.asset_type} has video solutions and/or explanations on each step. "

if asset.interactive == True and asset.with_solutions == True:
context += f"This {asset.asset_type} has a code solution on each step. "
context += f"This {asset.asset_type} has a model solution for each coding challenge on each step. "

if asset.duration:
context += f"This {asset.asset_type} will last {asset.duration} hours. "
if asset.duration and asset.duration > 0:
context += f"This {asset.asset_type} will takes {asset.duration} hours to complete (in average). "

if asset.difficulty:
context += f"Its difficulty is considered as {asset.difficulty}. "
Expand All @@ -667,7 +671,7 @@ def async_build_asset_context(asset_id):

if asset.asset_type == "PROJECT" and asset.delivery_instructions and asset.delivery_formats:
context += (
f"This project should be delivered by adding a file of one of these types: {asset.delivery_formats}. "
f"This project should be delivered by adding at least one file of one of these types: {asset.delivery_formats}. "
)

if asset.asset_type == "PROJECT" and asset.delivery_regex_url:
Expand Down
2 changes: 1 addition & 1 deletion breathecode/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _call(self, method_name, action_name, params=None, json=None):
}

url = self.HOST + action_name
resp = requests.request(method=method_name, url=url, headers=self.headers, params=params, json=json, timeout=2)
resp = requests.request(method=method_name, url=url, headers=self.headers, params=params, json=json, timeout=20)

if resp.status_code >= 200 and resp.status_code < 300:
if method_name in ["DELETE", "HEAD"]:
Expand Down
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.12.7
python-3.12.8

0 comments on commit fdf3f04

Please sign in to comment.