Skip to content

Commit

Permalink
Merge pull request #108 from diging/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
erickpeirson authored May 25, 2017
2 parents 19277ce + 6ffb7d5 commit 7927845
Show file tree
Hide file tree
Showing 646 changed files with 40,227 additions and 5,453 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ services:
- postgresql
env:
global:
- DJANGO_SETTINGS_MODULE=vogon.local_settings
- DJANGO_SETTINGS_MODULE=vogon.settings
- REDIS_URL=redis://
- CELERY_TASK_SERIALIZER=json
- DATABASE_URL=postgres://vogonweb:vogonweb@localhost:5432/vogonweb
before_script:
- psql -c 'create database vogonweb;' -U postgres
- psql -c "create role vogonweb with password 'vogonweb'; alter role vogonweb createdb; alter role vogonweb login;" -U postgres
script:
- python manage.py test
1 change: 0 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
web: gunicorn vogon.wsgi --log-file=-
worker: celery worker -B -A vogon
29 changes: 14 additions & 15 deletions annotations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@ class VogonUserAdmin(UserAdmin):
# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('email', 'affiliation', 'is_admin')
list_display = ('username', 'full_name', 'email', 'affiliation', 'is_admin')
list_filter = ('is_admin',)
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal info', {
'fields': ('full_name', 'affiliation', 'location', 'link', )
'fields': ('full_name', 'affiliation', 'location', 'link',
'conceptpower_uri')
}),
('Permissions', {'fields': ('is_admin',)}),
('Permissions', {'fields': ('is_admin', 'is_active')}),
)
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
# overrides get_fieldsets to use this attribute when creating a user.
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'password1', 'password2', 'full_name', 'affiliation', 'location')}
),
'fields': ('email', 'password1', 'password2', 'full_name',
'affiliation', 'location')
}),
)
search_fields = ('email',)
ordering = ('email',)
Expand Down Expand Up @@ -63,25 +65,24 @@ def submit_relationsets(modeladmin, request, queryset):
# involve concepts that are not resolved.
all_rsets = [rs for rs in queryset if rs.ready()]

project_grouper = lambda rs: getattr(rs.occursIn.partOf.first(), 'quadriga_id', -1)
project_grouper = lambda rs: getattr(rs.project, 'quadriga_id', -1)
for project_id, project_group in groupby(sorted(all_rsets, key=project_grouper), key=project_grouper):
print project_id
for text_id, text_group in groupby(project_group, key=lambda rs: rs.occursIn.id):
text = Text.objects.get(pk=text_id)
for user_id, user_group in groupby(text_group, key=lambda rs: rs.createdBy.id):
user = VogonUser.objects.get(pk=user_id)
# We lose the iterator after the first pass, so we want a list here.
rsets = []
for rs in user_group:
rsets.append(rs)
rsets.append(rs.id)
rs.pending = True
rs.save()
kwargs = {}
if project_id:
kwargs.update({
'project_id': project_id,
})
submit_relationsets_to_quadriga.delay(rsets, text, user, **kwargs)
submit_relationsets_to_quadriga.delay(rsets, text.id, user.id, **kwargs)


def submit_relationsets_synch(modeladmin, request, queryset):
Expand All @@ -98,25 +99,24 @@ def submit_relationsets_synch(modeladmin, request, queryset):
# involve concepts that are not resolved.
all_rsets = [rs for rs in queryset if rs.ready()]

project_grouper = lambda rs: getattr(rs.occursIn.partOf.first(), 'quadriga_id', -1)
project_grouper = lambda rs: getattr(rs.project, 'quadriga_id', -1)
for project_id, project_group in groupby(sorted(all_rsets, key=project_grouper), key=project_grouper):
print project_id
for text_id, text_group in groupby(project_group, key=lambda rs: rs.occursIn.id):
text = Text.objects.get(pk=text_id)
for user_id, user_group in groupby(text_group, key=lambda rs: rs.createdBy.id):
user = VogonUser.objects.get(pk=user_id)
# We lose the iterator after the first pass, so we want a list here.
rsets = []
for rs in user_group:
rsets.append(rs)
rsets.append(rs.id)
rs.pending = True
rs.save()
kwargs = {}
if project_id:
if project_id and project_id > 0:
kwargs.update({
'project_id': project_id,
})
submit_relationsets_to_quadriga(rsets, text, user, **kwargs)
submit_relationsets_to_quadriga(rsets, text.id, user.id, **kwargs)


class RelationSetAdmin(admin.ModelAdmin):
Expand All @@ -139,7 +139,6 @@ class Meta:
admin.site.register(Appellation, AppellationAdmin)
admin.site.register(Text, TextAdmin)
admin.site.register(TextCollection)
admin.site.register(Repository)
admin.site.register(Relation, RelationAdmin)
admin.site.register(RelationSet, RelationSetAdmin)
admin.site.register(RelationTemplate)
Expand Down
Loading

0 comments on commit 7927845

Please sign in to comment.