SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit ac4d671e authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Merge branch 'hotfix_JSC_20170726'

parents 9e989549 d65a3006
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@ from django import forms
from .models import Funder, Grant
from scipost.models import Contributor
class FunderRegistrySearchForm(forms.Form):
name = forms.CharField(max_length=128)
......@@ -9,7 +12,7 @@ class FunderRegistrySearchForm(forms.Form):
class FunderForm(forms.ModelForm):
class Meta:
model = Funder
fields = ['name', 'identifier',]
fields = ['name', 'acronym', 'identifier',]
class GrantForm(forms.ModelForm):
......@@ -17,6 +20,11 @@ class GrantForm(forms.ModelForm):
model = Grant
fields = ['funder', 'number', 'recipient_name', 'recipient',]
def __init__(self, *args, **kwargs):
super(GrantForm, self).__init__(*args, **kwargs)
self.fields['recipient'] = forms.ModelChoiceField(
queryset=Contributor.objects.all().order_by('user__last_name'))
class GrantSelectForm(forms.Form):
grant = forms.ModelChoiceField(queryset=Grant.objects.all())
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-07-26 18:37
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('funders', '0003_auto_20170726_0606'),
]
operations = [
migrations.AlterModelOptions(
name='funder',
options={'ordering': ['name', 'acronym']},
),
migrations.AddField(
model_name='funder',
name='acronym',
field=models.CharField(blank=True, max_length=32, null=True),
),
]
......@@ -7,13 +7,17 @@ class Funder(models.Model):
Fundref registry.
"""
name = models.CharField(max_length=256)
acronym = models.CharField(max_length=32, blank=True, null=True)
identifier = models.CharField(max_length=200, unique=True)
class Meta:
ordering = ['name']
ordering = ['name', 'acronym']
def __str__(self):
return self.name
result = self.name
if self.acronym:
result += ' (%s)' % self.acronym
return result
class Grant(models.Model):
......
......@@ -57,6 +57,7 @@
<thead class="thead-default">
<tr>
<th>Name</th>
<th>Acronym</th>
<th>Identifier</th>
</tr>
</thead>
......@@ -64,6 +65,7 @@
{% for funder in funders %}
<tr data-toggle="collapse" data-parent="#accordion" href="#collapse{{ funder.id }}" aria-expanded="true" aria-controls="collapse{{ funder.id }}" style="cursor: pointer;">
<td>{{ funder.name }}</td>
<td>{{ funder.acronym }}</td>
<td>{{ funder.identifier }}</td>
</tr>
{% empty %}
......
......@@ -29,6 +29,7 @@
<form action="{% url 'funders:add_funder' %}" method="post">
{% csrf_token %}
<input name='name' style="width: 64%" value='{{ item.name }}'>
<input name='acronym' style="width: 64%" placeholder='acronym (if known)'>
<input name='identifier' style="width: 64%" value='{{ item.uri }}'>
<input class="btn btn-secondary" type="submit" value="Add this funder">
</form>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment