Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Continued to work on Fedora Batch and MARC batch apps

  • Loading branch information...
commit d1b40edf403a4cda7fae54dc4fe162aefae7d803 1 parent 6ca722a
@jermnelson authored
View
BIN  aristotle/assets/img/fedora-commons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  fedora_batch/app_settings.py
@@ -18,7 +18,8 @@
APP = {'current_view': {'title':'Fedora Batch'},
'description': 'The Fedora Batch App provides a batch utilties for a Fedora Commons Repository',
- 'icon_url':'title-search.png',
+ 'icon_url':'fedora-commons.png',
+ 'productivity':True,
'url':'fedora_batch/'}
fedora_repo = FCRepoRestAPI(repository_url=FEDORA_URL,
View
18 fedora_batch/forms.py
@@ -0,0 +1,18 @@
+from django import forms
+from fedora_batch.models import *
+
+class BatchIngestForm(forms.Form):
+ metadata_template = forms.FileField()
+ target_directory = forms.CharField(max_length=255)
+
+class BatchModifyMetadataForm(forms.ModelForm):
+
+ class Meta:
+ model = BatchModifyMetadataLog
+ exclude = ('created_on')
+
+class ObjectMovementForm(forms.ModelForm):
+
+ class Meta:
+ model = ObjectMovementLog
+
View
49 fedora_batch/models.py
@@ -1,3 +1,50 @@
+"""
+ :mod:`fedora_batch.models` Module contains models using Django and Fedora
+ Commons for basic batch operatiosn for repository management.
+"""
+
from django.db import models
+from django.contrib.auth.models import User
+
+class BatchIngestLog(models.Model):
+ """
+ :class:`BatchIngestLog` logs batch ingest of objects into
+ Fedora Commons repository.
+ """
+ created_on = models.DateTimeField(auto_now_add=True)
+ fedora_url = models.URLField()
+ pids = models.ManyToManyField('PersisentIdentifer')
+
+class BatchModifyMetadataLog(models.Model):
+ """
+ :class:`BatchModifyMetadataLog` logs all batch metadata modifications
+ to one or more objects in the Fedora Commons repository.
+ """
+ created_on = models.DateTimeField(auto_now_add=True)
+ fedora_url = models.URLField()
+ metadata = models.TextField()
+ pids = models.ManyToManyField('PersisentIdentifer')
+
+class ObjectMovementLog(models.Model):
+ """
+ :class:`ObjectMovementLog` logs `PersisentIdentifer` movement within the Fedora
+ Commons Digital Repository
+ """
+ collection_pid = models.ForeignKey('PersisentIdentifer',
+ related_name="new_collection")
+ created_on = models.DateTimeField(auto_now_add=True)
+ source_pid = models.ForeignKey('PersisentIdentifer')
+
+
+class PersisentIdentifer(models.Model):
+ """
+ :class:`PersisentIdentifer` or PID, is used to track app activity with
+ the Fedora Commons server.
+ """
+ created_on = models.DateTimeField(auto_now_add=True)
+ fedora_url = models.URLField()
+ identifier = models.CharField(max_length=50)
+
+
+
-# Create your models here.
View
22 fedora_batch/templates/fedora_batch/app.html
@@ -17,7 +17,7 @@
<div class="row-fluid">
{% comment %}START fedora batch nav DIV{% endcomment %}
<div class="span3">
- <ul data-spy="affix" class="nav nav-stacked" >
+ <ul data-spy="affix" class="nav nav-stacked affix" >
<li>
<i class="icon-chevron-right pull-right"></i>
<a href="#ingest">Batch Ingest</a>
@@ -35,15 +35,31 @@
</div>
{% comment %}START widget DIV{% endcomment %}
<div class="span7">
- <div name="ingest">
+ <div name="ingest" class="well">
<h2>Batch Ingest</h2>
<form>
- <label>Director location</label>
+ {{ ingest_form.as_p }}
<a href="#" class="btn btn-primary">Run</a>
</form>
</div>
+ <hr />
+ <div name="modify" class="well">
+ <h2>Batch Modify Metadata</h2>
+ <p>With this form you'll be able to modify the existing metadata for one
+ or more objects in a Fedora Commons server.</p>
+ <form>
+ {{ modify_form.as_p }}
+ </form>
+ </div>
+ <div name="mover" class="well">
+ <h2>PID Mover</h2>
+ <p>Moves a single object or collection in a Fedora Commons Server</p>
+ <form>
+ {{ object_mover_form.as_p }}
+ </form>
{% comment %}END widget DIV{% endcomment %}
</div>
+
{% comment %}END row-fluid DIV{% endcomment %}
</div>
{% comment %}END content DIV{% endcomment %}
View
9 fedora_batch/views.py
@@ -4,6 +4,7 @@
from app_settings import APP,fedora_repo
from aristotle.settings import INSTITUTION
from django.views.generic.simple import direct_to_template
+from fedora_batch.forms import *
def default(request):
"""
@@ -11,8 +12,14 @@ def default(request):
:param request: HTTP Request
"""
+ batch_ingest_form = BatchIngestForm()
+ batch_modify_form = BatchModifyMetadataForm()
+ object_mover_form = ObjectMovementForm()
return direct_to_template(request,
'fedora_batch/app.html',
{'app':APP,
- 'institution':INSTITUTION})
+ 'ingest_form':batch_ingest_form,
+ 'institution':INSTITUTION,
+ 'modify_form':batch_modify_form,
+ 'object_mover_form':object_mover_form})
View
16 marc_batch/templates/marc_batch/finished.html
@@ -4,19 +4,9 @@
{% block more-css %}{% endblock %}
-{% block body %}
- <div class="row-fluid main-pane">
- <div class="span2">
- <div class="well">
- <p>
- <a class="btn" href="/apps/{{ app.url}}">{{ app.current_view.title }} Home</a>
- </p>
- </div>
- </div>
- <div class="span8 well" id="job-details">
+{% block app-main-body %}
<h1>Finished {{ log.job.name }}</h1>
+ <p>
{{ log }}
-
- </div>
- </div>
+ </p>
{% endblock %}
View
33 marc_batch/templates/marc_batch/history.html
@@ -0,0 +1,33 @@
+{% extends 'marc-batch-app.html' %}
+{% load i18n %}
+
+{% block more-css %}{% endblock %}
+
+
+{% block app-main-body %}
+ <h1>History of {{ current_job.name }}</h1>
+ <table>
+ <tr>
+ <th>Date</th>
+ <th>Description</th>
+ <th>New Records</th>
+ <th>Overlaid</th>
+ <th>Rejected</th>
+ <th>File Downloads</th>
+ </tr>
+ {% for log in logs %}
+ <tr>
+ <td>{{ log.created_on|date:"d F Y h:i:s a"}}</td>
+ <td>{{ log.description }}</td>
+ <td>{{ log.new_records }}</td>
+ <td>{{ log.overlaid_records }}</td>
+ <td>{{ log.rejected_records }}</td>
+ <td>
+ <a class="btn btn-success btn-mini" href="/apps/{{ app.url }}download?log_pk={{ log.pk }}">Modified MARC File</a>
+ <br/>
+ <a class="btn btn-success btn-mini" href="/apps/{{ app.url }}download?original=yes&log_pk={{ log.pk }}">Original MARC File</a>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+{% endblock %}
View
1  marc_batch/urls.py
@@ -11,6 +11,7 @@
url(r'^finished/(\d+)/','job_finished',name='marc_batch-job-finished'),
url(r"^process$","job_process",name='marc_batch-job-process'),
url(r"^ils/","ils",name='marc_batch-app-ils'),
+ url(r"^jobs/(\d+)/history/$","job_history",name="marc_batch-job-history"),
url(r"^jobs/(\d+)/$","job_display",name="marc_batch-job-display"),
url(r"^redis/","redis",name='marc_batch-app-redis'),
url(r"^solr/","solr",name='marc_batch_app_solr'),
View
35 marc_batch/views.py
@@ -43,14 +43,22 @@ def download(request):
"""
Download modified MARC21 file
"""
- log_pk = request.session['log_pk']
+ if request.REQUEST.has_key("log_pk"):
+ log_pk = request.REQUEST["log_pk"]
+ else:
+ log_pk = request.session['log_pk']
record_log = ILSJobLog.objects.get(pk=log_pk)
- modified_file = open(record_log.modified_marc.path,'r')
- file_wrapper = FileWrapper(file(record_log.modified_marc.path))
+ if request.REQUEST.has_key("original"):
+ file_path = record_log.original_marc.path
+ else:
+ file_path = record_log.modified_marc.path
+ file_object = open(file_path,'r')
+ file_wrapper = FileWrapper(file(file_path))
+ filename = os.path.split(file_path)[1]
response = HttpResponse(file_wrapper,content_type='text/plain')
- filename = os.path.split(record_log.modified_marc.path)[1]
+ filename = os.path.split(file_path)[1]
response['Content-Disposition'] = 'attachment; filename=%s' % filename
- response['Content-Length'] = os.path.getsize(record_log.modified_marc.path)
+ response['Content-Length'] = os.path.getsize(file_path)
return response
def ils(request):
@@ -136,6 +144,23 @@ def job_display(request,job_pk):
'institution':INSTITUTION,
'marc_upload_form':marc_form})
+def job_history(request,job_pk):
+ """
+ Displays the history for a MARC batch job
+
+ :param request: HTTP request
+ :param job_pk: Django primary key for job
+ """
+ job = Job.objects.get(pk=job_pk)
+ job_logs = JobLog.objects.filter(job=job).order_by("created_on")
+ return direct_to_template(request,
+ 'marc_batch/history.html',
+ {'app':APP,
+ 'current_job':job,
+ 'institution':INSTITUTION,
+ 'logs':job_logs})
+
+
def job_finished(request,job_log_pk):
"""
Displays finished job
Please sign in to comment.
Something went wrong with that request. Please try again.