Skip to content

Commit 1cf1cdc

Browse files
author
Krystle Salazar
committed
Create and process Scholarship form submission
1 parent 8e580c3 commit 1cf1cdc

File tree

18 files changed

+297
-56
lines changed

18 files changed

+297
-56
lines changed

Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ django_compressor = "*"
1313
django-countries = "*"
1414
django-heroku = "*"
1515
django-libsass = "*"
16+
django-widget-tweaks = "*"
1617
gunicorn = "*"
1718
psycopg2 = "*"
1819
django-ordered-model = "*"

Pipfile.lock

+15-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

caselaw/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"legal_db.apps.LegalDBConfig",
4545
"ordered_model",
4646
"taggit",
47+
"widget_tweaks",
4748
]
4849

4950
MIDDLEWARE = [

legal_db/forms.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from django import forms
2+
3+
from .models import Link, Scholarship
4+
5+
6+
class LinkForm(forms.ModelForm):
7+
class Meta:
8+
model = Link
9+
exclude = ["notes"]
10+
11+
12+
class ScholarshipForm(forms.ModelForm):
13+
agreement = forms.BooleanField()
14+
15+
class Meta:
16+
model = Scholarship
17+
fields = [
18+
"contributor_name",
19+
"contributor_email",
20+
"license",
21+
"title",
22+
"publication_name",
23+
"publication_year",
24+
"authors",
25+
"summary",
26+
]

legal_db/migrations/0001_initial.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 3.0.7 on 2020-06-22 02:59
1+
# Generated by Django 3.0.8 on 2020-07-14 20:23
22

33
from django.db import migrations, models
44
import django.db.models.deletion
@@ -63,7 +63,7 @@ class Migration(migrations.Migration):
6363
('publication_year', models.PositiveSmallIntegerField(blank=True, null=True)),
6464
('authors', models.CharField(blank=True, max_length=255, null=True)),
6565
('link', models.ForeignKey(help_text='The link to the article.', on_delete=django.db.models.deletion.CASCADE, to='legal_db.Link')),
66-
('tags', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
66+
('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
6767
],
6868
options={
6969
'abstract': False,
@@ -88,7 +88,7 @@ class Migration(migrations.Migration):
8888
('background', models.TextField(blank=True, help_text='Describe the factual information that led to the lawsuit being filed, and explain what claims were filed in the lawsuit.', null=True)),
8989
('decision_year', models.PositiveSmallIntegerField(blank=True, help_text='Year of case resolution.', null=True)),
9090
('links', models.ManyToManyField(help_text='Include any links to pleadings, briefs, and opinions in the lawsuit, as well as blog posts, academic articles, or other relevant materials.', to='legal_db.Link')),
91-
('tags', taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
91+
('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
9292
],
9393
options={
9494
'abstract': False,

legal_db/models.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Meta:
2222

2323

2424
class LegalResource(BaseModel):
25+
"""Abstract Class to contain the commons attributes of Cases and Scholarship"""
26+
2527
license = models.CharField(
2628
max_length=50,
2729
blank=True,
@@ -31,7 +33,7 @@ class LegalResource(BaseModel):
3133
contributor_name = models.CharField(max_length=120)
3234
contributor_email = models.EmailField()
3335
summary = models.TextField(blank=True, null=True)
34-
tags = TaggableManager()
36+
tags = TaggableManager(blank=True)
3537

3638
class Status(models.IntegerChoices):
3739
UNREVIEWED = 1, _("Unreviewed")
@@ -110,7 +112,7 @@ class Scholarship(LegalResource):
110112
)
111113

112114
def __str__(self):
113-
return self.title
115+
return self.title or self.link.url
114116

115117

116118
class FAQ(BaseModel, OrderedModel):

legal_db/static/app.js

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
const tagsToggle = document.getElementById('tags-filter'),
2-
tagsSection = document.getElementById('tags'),
3-
tagsShow = document.getElementById('tags-show'),
4-
tagsHide = document.getElementById('tags-hide');
1+
const tagsToggle = document.getElementById('tags-filter');
52

6-
tagsToggle.addEventListener('click', () => {
7-
tagsSection.classList.toggle('is-hidden');
8-
tagsShow.classList.toggle('is-hidden');
9-
tagsHide.classList.toggle('is-hidden');
10-
if (tagsSection.classList.contains('is-hidden')) {
11-
tagsSection.setAttribute('aria-expanded', false);
12-
} else {
13-
tagsSection.setAttribute('aria-expanded', true);
14-
}
15-
});
3+
if (document.body.contains(tagsToggle)) {
4+
const tagsSection = document.getElementById('tags'),
5+
tagsShow = document.getElementById('tags-show'),
6+
tagsHide = document.getElementById('tags-hide');
167

17-
const tags = document.querySelectorAll('.tag');
18-
tags.forEach(tag => {
19-
tag.addEventListener('click', () => {
20-
tag.classList.toggle('selected');
21-
})
22-
});
8+
tagsToggle.addEventListener('click', () => {
9+
tagsSection.classList.toggle('is-hidden');
10+
tagsShow.classList.toggle('is-hidden');
11+
tagsHide.classList.toggle('is-hidden');
12+
if (tagsSection.classList.contains('is-hidden')) {
13+
tagsSection.setAttribute('aria-expanded', false);
14+
} else {
15+
tagsSection.setAttribute('aria-expanded', true);
16+
}
17+
});
18+
19+
const tags = document.querySelectorAll('.tag');
20+
tags.forEach(tag => {
21+
tag.addEventListener('click', () => {
22+
tag.classList.toggle('selected');
23+
})
24+
});
25+
}

legal_db/static/logo.svg

+23
Loading

legal_db/static/styles.scss

+14
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ body {
8181
color: $color-light-gray;
8282
}
8383

84+
.errorlist {
85+
color: $color-tomato;
86+
font-size: 0.9rem;
87+
}
88+
8489
.faq {
8590
&__content {
8691
border-bottom: 2px solid $color-light-gray;
@@ -128,6 +133,10 @@ body {
128133
}
129134
}
130135

136+
.form {
137+
max-width: 768px;
138+
}
139+
131140
.hero {
132141
background-color: $color-lighter-gray;
133142

@@ -164,6 +173,11 @@ body {
164173
}
165174
}
166175

176+
.required {
177+
color: darkred;
178+
font-weight: bold;
179+
}
180+
167181
.tags-filter {
168182
color: $color-dark-slate-blue;
169183
cursor: pointer;

0 commit comments

Comments
 (0)