Skip to content

Commit

Permalink
Install genanki for exporting corrections to Anki
Browse files Browse the repository at this point in the history
  • Loading branch information
danielzeljko committed Aug 30, 2023
1 parent 676fbae commit 96d140e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions langcorrect/corrections/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from langcorrect.posts.models import PostRow

# from genanki import Deck, Model, Note, Package

logger = logging.getLogger(__name__)

CSV_HEADERS = ["Original Sentence", "Corrected Sentence", "Correction Feedback", "Corrector"]
Expand All @@ -22,6 +24,9 @@ def __init__(self, post) -> None:
PostRow.available_objects.filter(post=post).exclude(order=EXCLUDE_TITLE_ROW).order_by("created")
)

# def export_anki(self) -> HttpResponse:
# pass

def export_csv(self) -> HttpResponse:
"""Export the post sentences and their corrections to a CSV file."""
output = StringIO()
Expand Down
4 changes: 2 additions & 2 deletions langcorrect/corrections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def export_corrections(request, slug):
export_format = request.GET.get("format", "").upper()

match export_format:
case FileFormat.ANKI:
pass
# case FileFormat.ANKI:
# return ExportCorrections(post).export_anki()
case FileFormat.CSV:
return ExportCorrections(post).export_csv()
case FileFormat.PDF:
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ django-cors-headers==4.2.0 # https://github.com/adamchainz/django-cors-headers
drf-spectacular==0.26.3 # https://github.com/tfranzel/drf-spectacular

weasyprint==59.0 # https://doc.courtbouillon.org/weasyprint/
genanki==0.13.0 # https://github.com/kerrickstaley/genanki

0 comments on commit 96d140e

Please sign in to comment.