Skip to content

Commit

Permalink
Merge branch '2.2.3' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Dec 8, 2021
2 parents 078637f + a72c843 commit da0df10
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

CHANGELOG
=========
Release 2.2.3
---------------------
* Added version number to template
* Bug fixes for missing author name in GitHub export

Release 2.2.2
---------------------
* Bug fixes for naming GitHub repository for export.
Expand Down
7 changes: 0 additions & 7 deletions apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
__version__ = "2.2.2"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num
for num in __version__.replace("-", ".", 1).split(".")
]
)
18 changes: 12 additions & 6 deletions apps/export/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
from django.core.serializers import serialize
from django.template.loader import get_template
from apps.users.models import User
from apps.readux import __version__
import digitaledition_jekylltheme
import config.settings.local as settings
from .github import GithubApi, GithubAccountNotFound


__version__ = "2.0.0"

LOGGER = logging.getLogger(__name__)

# zip file of base jekyll site with digital edition templates
Expand Down Expand Up @@ -89,7 +88,7 @@ def get_zip(self, manifest, version, owners=[]):
annotators = User.objects.filter(
userannotation__canvas__manifest__id=manifest.id
).distinct()
annotators_string = ', '.join([i.fullname() for i in annotators])
annotators_string = ', '.join([i.name for i in annotators])
# pylint: enable = possibly-unused-variable

# pylint: disable = line-too-long
Expand Down Expand Up @@ -550,12 +549,19 @@ def website_gitrepo(self):
# initialize export dir as a git repo, and commit the contents
# NOTE: to debug git commands, print the git return to see git output

git_author = None

if self.user.name is None or not self.user.name:
git_author = GithubApi.github_username(self.user)
else:
git_author = self.user.name

gitcmd = Git(jekyll_dir)
# initialize jekyll site as a git repo
gitcmd.init()
# add and commit all contents
gitcmd.config("user.email", self.user.email)
gitcmd.config("user.name", self.user.fullname())
gitcmd.config("user.name", git_author)
# Use the token to authenticate the Git commands.
# Required to do this as of June 9, 2020
# https://developer.github.com/changes/2020-02-14-deprecating-oauth-app-endpoint/
Expand All @@ -568,7 +574,7 @@ def website_gitrepo(self):
v=__version__
),
'--author="{fn} <{ue}>"'.format(
fn=self.user.fullname(),
fn=git_author,
ue=self.user.email
)
])
Expand Down Expand Up @@ -683,7 +689,7 @@ def update_gitrepo(self):
# TODO: if deep zoom is added, we must add that directory as well

git_author = git.Actor(
self.user.fullname(),
self.user.name,
self.user.email
)
# commit all changes
Expand Down
13 changes: 13 additions & 0 deletions apps/export/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ def list_user_repos(self):
return repos
return None

def list_repo_branches(self, repo, user):
"""List branches in repository
:param repo: Name of repository
:type repo: str
:param user: GitHub user
:type user: apps.users.models.User
:return: List of GitHub repository branch names.
:rtype: list
"""
response = self.session.get(f'{self.url}/{self.github_username(user)}/{repo}/branches')
return [branch['name'] for branch in response.json()]

def create_pull_request(self, repo, title, head, base, text=None):
"""Create a new pull request.
https://developer.github.com/v3/pulls/#create-a-pull-request
Expand Down
14 changes: 14 additions & 0 deletions apps/export/tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ def test_list_user_repos(self):
repos = self.gh.list_user_repos()
assert len(repos) == 6

@httpretty.activate
def test_repo_branches(self):
resp_body = '[{"name": "branch1", "commit": {"sha": "40767", "url": ""}, "protected": "False"}, {"name": "branch2", "commit": {"sha": "40767", "url": ""}, "protected": "False"}]'
httpretty.register_uri(
httpretty.GET,
f'https://api.github.com/{self.gh.github_username(self.user)}/some-repo/branches',
body=resp_body,
content_type="text/json"
)

branches = self.gh.list_repo_branches('some-repo', self.user)
assert len(branches) == 2
assert 'branch2' in branches

@httpretty.activate
def test_create_pr(self):
httpretty.register_uri(
Expand Down
2 changes: 1 addition & 1 deletion apps/readux/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.2'
__version__ = '2.2.3'
4 changes: 4 additions & 0 deletions apps/readux/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import __version__

def current_version(request=None):
return {'APP_VERSION': __version__}
10 changes: 6 additions & 4 deletions apps/readux/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from ..annotations import Annotations, AnnotationCrud
from django.contrib.auth import get_user_model
from django.urls import reverse
from django.template import Context, Template
from django.core.serializers import serialize
from apps.iiif.annotations.models import Annotation
from apps.iiif.manifests.models import Manifest
from apps import readux
from ..models import UserAnnotation
from apps.readux.views import VolumesList, VolumeDetail, CollectionDetail, Collection, ExportOptions, AnnotationsCount
from ..context_processors import current_version
from apps.readux.views import VolumesList, CollectionDetail, ExportOptions, AnnotationsCount
from urllib.parse import urlencode
from cssutils import parseString
import warnings
import json
import re
import uuid
Expand Down Expand Up @@ -597,3 +596,6 @@ def test_user_annotation_count(self):
assert response.context_data['page'] == self.canvas
assert response.context_data['user_annotation_page_count'] == 3
assert response.context_data['user_annotation_count'] == 3

def test_current_version_context(self):
assert readux.__version__ == current_version()['APP_VERSION']
2 changes: 1 addition & 1 deletion apps/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="uk-width-1-1">
<ul class="rx-footer uk-padding-remove">
<a href="http://digitalscholarship.emory.edu/projects/software/readux.html" target="_blank" alt="Readux by Emory Center for Digital Scholarship">
<li>Readux 2.0</li>
<li>Readux {{APP_VERSION}}</li>
</a>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
'apps.custom_styles.context_processors.add_custom_style',
'apps.templates.context_processors.has_ga_tracking_id',
'apps.templates.context_processors.ga_tracking_id',
'apps.readux.context_processors.current_version',
],
},
},
Expand Down
27 changes: 0 additions & 27 deletions readux/__init__.py

This file was deleted.

0 comments on commit da0df10

Please sign in to comment.