SciPost Code Repository

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

Add acronym to Funder

parent 342b1eca
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,9 @@ from django import forms ...@@ -2,6 +2,9 @@ from django import forms
from .models import Funder, Grant from .models import Funder, Grant
from scipost.models import Contributor
class FunderRegistrySearchForm(forms.Form): class FunderRegistrySearchForm(forms.Form):
name = forms.CharField(max_length=128) name = forms.CharField(max_length=128)
...@@ -9,7 +12,7 @@ class FunderRegistrySearchForm(forms.Form): ...@@ -9,7 +12,7 @@ class FunderRegistrySearchForm(forms.Form):
class FunderForm(forms.ModelForm): class FunderForm(forms.ModelForm):
class Meta: class Meta:
model = Funder model = Funder
fields = ['name', 'identifier',] fields = ['name', 'acronym', 'identifier',]
class GrantForm(forms.ModelForm): class GrantForm(forms.ModelForm):
...@@ -17,6 +20,11 @@ class GrantForm(forms.ModelForm): ...@@ -17,6 +20,11 @@ class GrantForm(forms.ModelForm):
model = Grant model = Grant
fields = ['funder', 'number', 'recipient_name', 'recipient',] 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): class GrantSelectForm(forms.Form):
grant = forms.ModelChoiceField(queryset=Grant.objects.all()) 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): ...@@ -7,13 +7,17 @@ class Funder(models.Model):
Fundref registry. Fundref registry.
""" """
name = models.CharField(max_length=256) name = models.CharField(max_length=256)
acronym = models.CharField(max_length=32, blank=True, null=True)
identifier = models.CharField(max_length=200, unique=True) identifier = models.CharField(max_length=200, unique=True)
class Meta: class Meta:
ordering = ['name'] ordering = ['name', 'acronym']
def __str__(self): def __str__(self):
return self.name result = self.name
if self.acronym:
result += ' (%s)' % self.acronym
return result
class Grant(models.Model): class Grant(models.Model):
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
<thead class="thead-default"> <thead class="thead-default">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Acronym</th>
<th>Identifier</th> <th>Identifier</th>
</tr> </tr>
</thead> </thead>
...@@ -64,6 +65,7 @@ ...@@ -64,6 +65,7 @@
{% for funder in funders %} {% 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;"> <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.name }}</td>
<td>{{ funder.acronym }}</td>
<td>{{ funder.identifier }}</td> <td>{{ funder.identifier }}</td>
</tr> </tr>
{% empty %} {% empty %}
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<form action="{% url 'funders:add_funder' %}" method="post"> <form action="{% url 'funders:add_funder' %}" method="post">
{% csrf_token %} {% csrf_token %}
<input name='name' style="width: 64%" value='{{ item.name }}'> <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 name='identifier' style="width: 64%" value='{{ item.uri }}'>
<input class="btn btn-secondary" type="submit" value="Add this funder"> <input class="btn btn-secondary" type="submit" value="Add this funder">
</form> </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