-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from gwu-libraries/t14-add-seed-seedsets-try2
T14 add seed seedsets try2
- Loading branch information
Showing
25 changed files
with
749 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ django>=1.8,<=1.9 | |
django-allauth | ||
psycopg2 | ||
pytz | ||
appdeps | ||
django-crispy-forms | ||
appdeps |
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,3 +1,90 @@ | ||
from django.contrib import admin | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
# Register your models here. | ||
from django import forms | ||
from django.contrib import admin as a | ||
from ui import models as m | ||
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin | ||
from django.contrib.auth.forms import UserChangeForm, UserCreationForm | ||
|
||
from .models import User | ||
|
||
|
||
class MyUserChangeForm(UserChangeForm): | ||
class Meta(UserChangeForm.Meta): | ||
model = User | ||
|
||
|
||
class MyUserCreationForm(UserCreationForm): | ||
|
||
error_message = UserCreationForm.error_messages.update({ | ||
'duplicate_local_id': 'This local_id has already been taken.' | ||
}) | ||
|
||
class Meta(UserCreationForm.Meta): | ||
model = User | ||
|
||
def clean_local_id(self): | ||
local_id = self.cleaned_data["local_id"] | ||
try: | ||
User.objects.get(local_id=local_id) | ||
except User.DoesNotExist: | ||
return local_id | ||
raise forms.ValidationError(self.error_messages['duplicate_local_id']) | ||
|
||
|
||
@a.register(User) | ||
class UserAdmin(AuthUserAdmin): | ||
form = MyUserChangeForm | ||
add_form = MyUserCreationForm | ||
|
||
|
||
class Credential(a.ModelAdmin): | ||
fields = ('user', 'platform', 'token', 'is_active', 'date_added') | ||
list_display = ['user', 'platform', 'token', 'is_active', 'date_added'] | ||
list_filter = ['user', 'platform', 'token', 'is_active', 'date_added'] | ||
search_fields = ['user', 'platform', 'token', 'is_active', 'date_added'] | ||
|
||
|
||
class Collection(a.ModelAdmin): | ||
fields = ('group', 'name', 'description', 'is_active', 'is_visible', | ||
'stats', 'date_added') | ||
list_display = ['group', 'name', 'description', 'is_active', 'is_visible', | ||
'stats', 'date_added', 'date_updated'] | ||
list_filter = ['group', 'name', 'description', 'is_active', 'is_visible', | ||
'stats', 'date_added', 'date_updated'] | ||
search_fields = ['group', 'name', 'description', 'is_active', 'is_visible', | ||
'stats', 'date_added', 'date_updated'] | ||
|
||
|
||
class SeedSet(a.ModelAdmin): | ||
fields = ('collection', 'credential', 'harvest_type', 'name', 'description', | ||
'is_active', 'schedule', 'harvest_options', 'max_count', 'stats', | ||
'date_added', 'start_date', 'end_date') | ||
list_display = ['collection', 'credential', 'harvest_type', 'name', | ||
'description', 'is_active', 'schedule', 'harvest_options', | ||
'max_count', 'stats', 'date_added', 'start_date', | ||
'end_date'] | ||
list_filter = ['collection', 'credential', 'harvest_type', 'name', | ||
'description', 'is_active', 'schedule', 'harvest_options', | ||
'max_count', 'stats', 'date_added', 'start_date', | ||
'end_date'] | ||
search_fields = ['collection', 'credential', 'harvest_type', 'name', | ||
'description', 'is_active', 'schedule', 'harvest_options', | ||
'max_count', 'stats', 'date_added', 'start_date', | ||
'end_date'] | ||
|
||
|
||
class Seed(a.ModelAdmin): | ||
fields = ('seed_set', 'token', 'uid', 'is_active', | ||
'is_valid', 'stats', 'date_added') | ||
list_display = ['seed_set', 'token', 'uid', 'is_active', | ||
'is_valid', 'stats', 'date_added', 'date_updated'] | ||
list_filter = ['seed_set', 'token', 'uid', 'is_active', | ||
'is_valid', 'stats', 'date_added', 'date_updated'] | ||
search_fields = ['seed_set', 'token', 'uid', 'is_active', | ||
'is_valid', 'stats', 'date_added', 'date_updated'] | ||
|
||
a.site.register(m.Credential, Credential) | ||
a.site.register(m.Collection, Collection) | ||
a.site.register(m.SeedSet, SeedSet) | ||
a.site.register(m.Seed, Seed) |
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,77 @@ | ||
from django import forms | ||
from .models import Collection, SeedSet, Seed | ||
|
||
|
||
class CollectionForm(forms.ModelForm): | ||
|
||
class Meta: | ||
model = Collection | ||
fields = '__all__' | ||
exclude = [] | ||
widgets = None | ||
localized_fields = None | ||
labels = {} | ||
help_texts = {} | ||
error_messages = {} | ||
|
||
def __init__(self, *args, **kwargs): | ||
return super(CollectionForm, self).__init__(*args, **kwargs) | ||
|
||
def is_valid(self): | ||
return super(CollectionForm, self).is_valid() | ||
|
||
def full_clean(self): | ||
return super(CollectionForm, self).full_clean() | ||
|
||
def save(self, commit=True): | ||
return super(CollectionForm, self).save(commit) | ||
|
||
|
||
class SeedSetForm(forms.ModelForm): | ||
|
||
class Meta: | ||
model = SeedSet | ||
fields = '__all__' | ||
exclude = [] | ||
widgets = None | ||
localized_fields = None | ||
labels = {} | ||
help_texts = {} | ||
error_messages = {} | ||
|
||
def __init__(self, *args, **kwargs): | ||
return super(SeedSetForm, self).__init__(*args, **kwargs) | ||
|
||
def is_valid(self): | ||
return super(SeedSetForm, self).is_valid() | ||
|
||
def full_clean(self): | ||
return super(SeedSetForm, self).full_clean() | ||
|
||
def save(self, commit=True): | ||
return super(SeedSetForm, self).save(commit) | ||
|
||
|
||
class SeedForm(forms.ModelForm): | ||
|
||
class Meta: | ||
model = Seed | ||
fields = '__all__' | ||
exclude = [] | ||
widgets = None | ||
localized_fields = None | ||
labels = {} | ||
help_texts = {} | ||
error_messages = {} | ||
|
||
def __init__(self, *args, **kwargs): | ||
return super(SeedForm, self).__init__(*args, **kwargs) | ||
|
||
def is_valid(self): | ||
return super(SeedForm, self).is_valid() | ||
|
||
def full_clean(self): | ||
return super(SeedForm, self).full_clean() | ||
|
||
def save(self, commit=True): | ||
return super(SeedForm, self).save(commit) |
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,44 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ui', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='seed', | ||
old_name='platform_token', | ||
new_name='token', | ||
), | ||
migrations.RenameField( | ||
model_name='seed', | ||
old_name='platform_uid', | ||
new_name='uid', | ||
), | ||
migrations.RenameField( | ||
model_name='seedset', | ||
old_name='date_ended', | ||
new_name='end_date', | ||
), | ||
migrations.RenameField( | ||
model_name='seedset', | ||
old_name='crawl_options', | ||
new_name='harvest_options', | ||
), | ||
migrations.RenameField( | ||
model_name='seedset', | ||
old_name='platform', | ||
new_name='harvest_type', | ||
), | ||
migrations.RenameField( | ||
model_name='seedset', | ||
old_name='date_started', | ||
new_name='start_date', | ||
), | ||
] |
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,16 @@ | ||
{% extends 'base.html' %} | ||
{% load crispy_forms_tags %} | ||
{% block title %} | ||
Create Collection | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1><a href={% url "collection_list" %}>Collection</a></h1> | ||
<h2>Create Collection</h2> | ||
|
||
<form action="" method="post">{% csrf_token %} | ||
{{ form|crispy }} | ||
<input type="submit" value="Create" /> | ||
</form> | ||
<a href={% url "collection_list" %}>Cancel</a> | ||
{% endblock %} |
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,17 @@ | ||
{% extends 'base.html' %} | ||
{% load crispy_forms_tags %} | ||
{% block title %} | ||
Delete {{ collection }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1>Delete {{ collection }}</h1> | ||
|
||
<form action="" method="post">{% csrf_token %} | ||
<p>Are you sure you want to delete {{ collection }}?</p> | ||
<input type="submit" value="Confirm" /> | ||
</form> | ||
|
||
<a href={% url "collection_detail" collection.pk %}>Cancel</a> | ||
|
||
{% endblock %} |
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,24 @@ | ||
{% extends 'base.html' %} | ||
{% load crispy_forms_tags %} | ||
{% block title %} | ||
{{ collection }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1><a href={% url "collection_list" %}>Collection</a></h1> | ||
<h2>{{ collection }} | <a href={% url "collection_update" collection.pk %}>Update</a> | | ||
<form style="display:inline;" action={% url "collection_delete" collection.pk %} method="post" onsubmit="return confirm('Are you sure you want to delete {{ collection }}?')">{% csrf_token %} | ||
<input type="submit" value="Delete" /> | ||
<div> | ||
<li>Group : {{ collection.group }}</li> | ||
<li>Name : {{ collection.name }}</li> | ||
<li>Description : {{ collection.description }}</li> | ||
<li>date_updated : {{ collection.date_updated }}</li> | ||
<li>date_added : {{ collection.date_added }}</li> | ||
<li>is_visible : {{ collection.is_visible }}</li> | ||
<li>is_active : {{ collection.is_active }}</li> | ||
<li>stats : {{ collection.stats }}</li> | ||
</div> | ||
</form> | ||
</h2> | ||
{% endblock %} |
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,19 @@ | ||
{% extends 'base.html' %} | ||
{% load crispy_forms_tags %} | ||
{% block title %} | ||
Collections | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1>Collections</h1> | ||
<h2><a href={% url "collection_create" %}>Create new Collection</h2> | ||
<ul> | ||
{% for collection in collection_list %} | ||
<li><a href={% url "collection_detail" collection.pk %}>{{ collection }}</a> | <a href={% url "collection_update" collection.pk %}>Update</a> | <form style="display:inline;" action={% url "collection_delete" collection.pk %} method="post" onsubmit="return confirm('Are you sure you want to delete {{ collection }}?')">{% csrf_token %} | ||
<input type="submit" value="Delete" /> | ||
</form></li> | ||
{% empty %} | ||
<li>No Collections yet.</li> | ||
{% endfor %} | ||
</ul> | ||
{% endblock %} |
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,19 @@ | ||
{% extends 'base.html' %} | ||
{% load crispy_forms_tags %} | ||
{% block title %} | ||
Update {{ collection }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1><a href={% url "collection_list" %}>Collection</a></h1> | ||
<h2>Update {{ collection }}</h2> | ||
|
||
<form action="" method="post">{% csrf_token %} | ||
{{ form|crispy }} | ||
<input type="submit" value="Update" /> | ||
</form> | ||
<a href={% url "collection_detail" collection.pk %}>Cancel</a> | ||
<form style="display:inline;" action={% url "collection_delete" collection.pk %} method="post" onsubmit="return confirm('Are you sure you want to delete {{ collection }}?')">{% csrf_token %} | ||
<input type="submit" value="Delete" /> | ||
</form> | ||
{% endblock %} |
Oops, something went wrong.