-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
100 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.14 on 2024-01-11 14:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('jdhapi', '0038_article_dataverse_url'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='article', | ||
name='full_url_article_path', | ||
field=models.CharField(blank=True, help_text='Full URL of the article', max_length=254, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
from django.db.models.signals import pre_save, post_save | ||
from django.core.mail import send_mail | ||
from jdhapi.models import Article | ||
from django.dispatch import receiver | ||
from jdhapi.utils.articleUtils import get_notebook_from_github | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@receiver(post_save, sender=Article) | ||
def send_email_for_peer_review_article(sender, instance, created, **kwargs): | ||
if not created and instance.tracker.has_changed('status') and instance.status == Article.Status.PEER_REVIEW: | ||
instance.send_email_if_peer_review() | ||
|
||
@receiver(pre_save, sender=Article) | ||
def pre_save_article(sender, instance, **kwargs): | ||
logger.debug("Inside pre_save_article") | ||
|
||
# Check if full_url_article_path has changed | ||
if instance.tracker.has_changed('full_url_article_path'): | ||
# Update other fields if necessary | ||
repository_url, notebook_path, notebook_ipython_url = get_notebook_from_github(instance.full_url_article_path) | ||
|
||
# Set the values directly without calling save | ||
instance.notebook_ipython_url = notebook_ipython_url | ||
instance.repository_url = repository_url | ||
instance.notebook_path = notebook_path | ||
|
||
logger.debug("Fields populated: notebook_ipython_url=%s, repository_url=%s, notebook_path=%s" % ( | ||
instance.notebook_ipython_url, instance.repository_url, instance.notebook_path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import subprocess | ||
|
||
notebook_file = 'notebook_with_ref.ipynb' | ||
output_format = 'pdf' | ||
command = f'jupyter nbconvert --to {output_format} {notebook_file}' | ||
|
||
try: | ||
result = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT, text=True) | ||
print("Conversion successful!") | ||
print(result) # Print the entire output | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error during conversion: {e}") | ||
print("Command output:\n", e.output) |