Skip to content

Commit

Permalink
update bag-it profile creation form
Browse files Browse the repository at this point in the history
  • Loading branch information
HaSistrunk committed Oct 22, 2024
1 parent fd06ce2 commit f321e03
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 239 deletions.
112 changes: 65 additions & 47 deletions bag_transfer/bagit_profiles/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Meta:
labels = {
"external_description": "Description",
"allow_fetch": "Allow Fetch.txt?",
"serialization": "Serialization allowed?",
"serialization": "Serialization Allowed?",
}
widgets = {
"organization": forms.widgets.HiddenInput(),
Expand All @@ -23,20 +23,24 @@ class Meta:
"version": forms.widgets.HiddenInput(),
"bagit_profile_identifier": forms.widgets.HiddenInput(),
"external_description": forms.widgets.Textarea(
attrs={"class": "form-control", "rows": 3}
),
"serialization": forms.widgets.Select(
attrs={
"class": "form-control",
"aria-labelledby": "id_serialization-label",
"rows": 3,
"aria-describedby": "id_external_description-help"
}
),
"allow_fetch": forms.widgets.CheckboxInput(attrs={"class": "checkbox checkbox--blue"}),
"serialization": forms.widgets.RadioSelect(),
}
help_texts = {
"external_description": "A short description of this BagIt Profile.",
"serialization": "Specify whether serialization of bags is required, forbidden, or optional.",
}
# Set most common initial values
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.fields['external_description'].initial = f"BagIt Profile for transferring records to the Rockefeller Archive Center."
self.fields['serialization'].required = True

class BagItProfileBagInfoForm(forms.ModelForm):
class Meta:
Expand All @@ -48,9 +52,9 @@ class Meta:
"repeatable": "Repeatable?",
}
widgets = {
"field": forms.widgets.Select(attrs={"class": "form-control multi-value"}),
"required": forms.widgets.CheckboxInput(),
"repeatable": forms.widgets.CheckboxInput(),
"field": forms.widgets.Select(),
"required": forms.widgets.CheckboxInput(attrs={"class": "checkbox checkbox--blue"}),
"repeatable": forms.widgets.CheckboxInput(attrs={"class": "checkbox checkbox--blue"}),
}


Expand All @@ -60,82 +64,97 @@ class Meta:
fields = ("name",)
widgets = {
"name": forms.widgets.TextInput(
attrs={
"class": "form-control multi-value",
"aria-labelledby": "values-label",
}
)
attrs={"aria-labelledby": "values-label",})
}


class ManifestsAllowedForm(forms.ModelForm):
class Meta:
model = ManifestsAllowed
fields = ("name",)
widgets = {
"name": forms.widgets.Select(
attrs={
"class": "form-control multi-value",
"aria-labelledby": "manifests_allowed-label",
}
)
"name": forms.widgets.CheckboxSelectMultiple(
attrs={"class": "checkbox checkbox--blue"})
}
help_texts = {
"name": "Select at least one."
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.legend_text = "Allowed algorithm(s) for manifest files *"
self.help_text_id = "manifests_allowed-help"
self.fields['name'].required = True

class ManifestsRequiredForm(forms.ModelForm):
class Meta:
model = ManifestsRequired
fields = ("name",)
widgets = {
"name": forms.widgets.Select(
attrs={
"class": "form-control multi-value",
"aria-labelledby": "manifests-label",
}
)
"name": forms.widgets.CheckboxSelectMultiple(
attrs={"class": "checkbox checkbox--blue"})
}
help_texts = {
"name": "If no value is selected, any algorithm is valid."
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.legend_text = "Manifests Required"
self.help_text_id = "manifests_required-help"


class AcceptSerializationForm(forms.ModelForm):
class Meta:
model = AcceptSerialization
fields = ("name",)
widgets = {
"name": forms.widgets.Select(
attrs={
"class": "form-control multi-value",
"aria-labelledby": "serialization-label",
}
)
"name": forms.widgets.CheckboxSelectMultiple(
attrs={"class": "checkbox checkbox--blue"})
}
help_texts = {
"name": "Select all accepted formats. If no values are selected, the serialization format will not be checked."
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.legend_text = "Serializations Accepted"
self.help_text_id = "serializations_accepted-help"


class AcceptBagItVersionForm(forms.ModelForm):
class Meta:
model = AcceptBagItVersion
fields = ("name",)
widgets = {
"name": forms.widgets.Select(
attrs={
"class": "form-control multi-value",
"aria-labelledby": "version-label",
}
)
"name": forms.widgets.CheckboxSelectMultiple(
attrs={"class": "checkbox checkbox--blue"})
}
help_texts = {
"name": "Select all versions of the BagIt Specification accepted. If no values are selected, the BagIt version will not be checked."
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.legend_text = "BagIt Versions Accepted"
self.help_text_id = "bagit_versions_accepted-help"


class TagManifestsRequiredForm(forms.ModelForm):
class Meta:
model = TagManifestsRequired
fields = ("name",)
widgets = {
"name": forms.widgets.Select(
attrs={
"class": "form-control multi-value",
"aria-labelledby": "tag_manifests-label",
}
)
"name": forms.widgets.CheckboxSelectMultiple(
attrs={"class": "checkbox checkbox--blue"})
}
help_texts = {
"name": "If no values are selected, the tag format algorithm will not be checked."
}

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.legend_text = "Tag Manifests Required"
self.help_text_id = "tag_manifests_required-help"


class TagFilesRequiredForm(forms.ModelForm):
Expand All @@ -144,8 +163,7 @@ class Meta:
fields = ("name",)
widgets = {
"name": forms.widgets.TextInput(
attrs={"class": "form-control", "aria-labelledby": "tag_files-label"}
)
attrs={"aria-describedby": "tag_files-help", "aria-labelledby": "tag_files-label"})
}


Expand Down
10 changes: 5 additions & 5 deletions bag_transfer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,13 @@ class BagItProfile(models.Model):

class ManifestsAllowed(models.Model):
MANIFESTS_ALLOWED_CHOICES = (("sha256", "sha256"), ("sha512", "sha512"))
name = models.CharField(choices=MANIFESTS_ALLOWED_CHOICES, max_length=20)
name = models.CharField(choices=MANIFESTS_ALLOWED_CHOICES, max_length=20, default=("sha256", "sha512"))
bagit_profile = models.ForeignKey(BagItProfile, on_delete=models.CASCADE, related_name="manifests_allowed")


class ManifestsRequired(models.Model):
MANIFESTS_REQUIRED_CHOICES = (("sha256", "sha256"), ("sha512", "sha512"))
name = models.CharField(choices=MANIFESTS_REQUIRED_CHOICES, max_length=20)
name = models.CharField(choices=MANIFESTS_REQUIRED_CHOICES, max_length=20, default=(None))
bagit_profile = models.ForeignKey(BagItProfile, on_delete=models.CASCADE, related_name="manifests_required")


Expand All @@ -791,7 +791,7 @@ class AcceptSerialization(models.Model):
("application/x-tar", "application/x-tar"),
("application/x-gzip", "application/x-gzip"),
)
name = models.CharField(choices=ACCEPT_SERIALIZATION_CHOICES, max_length=25)
name = models.CharField(choices=ACCEPT_SERIALIZATION_CHOICES, max_length=25, default=("application/zip", "application/x-tar", "application/x-gzip"))
bagit_profile = models.ForeignKey(BagItProfile, on_delete=models.CASCADE, related_name="accept_serialization")


Expand All @@ -801,13 +801,13 @@ class AcceptBagItVersion(models.Model):
("0.97", "0.97"),
("1.0", "1.0"),
)
name = models.CharField(choices=BAGIT_VERSION_NAME_CHOICES, max_length=5)
name = models.CharField(choices=BAGIT_VERSION_NAME_CHOICES, max_length=5, default=("0.97"))
bagit_profile = models.ForeignKey(BagItProfile, on_delete=models.CASCADE, related_name="accept_bagit_version")


class TagManifestsRequired(models.Model):
TAG_MANIFESTS_REQUIRED_CHOICES = (("sha256", "sha256"), ("sha512", "sha512"))
name = models.CharField(choices=TAG_MANIFESTS_REQUIRED_CHOICES, max_length=20)
name = models.CharField(choices=TAG_MANIFESTS_REQUIRED_CHOICES, max_length=20, default=(None))
bagit_profile = models.ForeignKey(
BagItProfile, on_delete=models.CASCADE, related_name="tag_manifests_required"
)
Expand Down
82 changes: 66 additions & 16 deletions bag_transfer/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ h1 {
line-height: 16px;
padding: 3px;
font-weight: bold;
margin-bottom: 3px;
}

.btn--xs .material-icon {
font-size: 18px;
}

/**
Expand Down Expand Up @@ -303,6 +306,53 @@ form, .input input, .input textarea, .input select {
display: block;
}

.dynamic-form {
flex-wrap: flex;

@media screen and (min-width: 1024px) {
display: flex;
}
}

.dynamic-form__btns {
display: flex;
margin: 5px 0;

@media screen and (min-width: 1024px) {
margin: 3px 0 0 5px;
}
}

.dynamic-form__input {
flex-basis: 80%;
}

.nested-form {
align-items: center;
flex-grow: 1;
flex-wrap: wrap;
}

.values-form__input {
width: 100%;

@media screen and (min-width: 1024px) {
width: 75%;
}
}

.values-inputs div, .tag-files {
align-items: center;
margin-bottom: 5px;
}

.delete-field__btn {
@media screen and (min-width: 1024px) {
margin-left: auto;
align-self: flex-start;
}
}

/**
* Accession form layout
**/
Expand Down Expand Up @@ -347,6 +397,21 @@ form, .input input, .input textarea, .input select {
}
}

.input__form-layout {
width: 100%;

@media screen and (min-width: 1024px) {
width: 50%;
}
}

/**
* Enable javascript ability to hide form elements
**/
.hidden {
display: none;
}

/**
* Accession form AS resource name and dismiss button styles
**/
Expand All @@ -363,21 +428,6 @@ form, .input input, .input textarea, .input select {
outline-color: #f6f6f4;
}

/**
* User/Org create form input layout
**/
.input__form-layout {
width: 100%;

@media screen and (min-width: 580px) {
width: 50%;
}

@media screen and (min-width: 1024px) {
width: 33%;
}
}


/* @import url('https://fonts.googleapis.com/css?family=Satisfy');
Expand Down
30 changes: 15 additions & 15 deletions bag_transfer/templates/bagit_profiles/baginfo_form_fields.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{% for field in form.visible_fields %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{% if field.label != "Delete" %}
<label id="{{field.id_for_label}}-label" for="{{field.id_for_label}}">{{field.label}}{% if field.field.required %} *{% endif %}</label>
{% endif %}
{{ field }}
{% if field.help_text %}
<p class="help-block">{{field.help_text}}</p>
{% endif %}
{% if field.errors %}
{% for error in field.errors %}
<p class="help-block">{{error}}</p>
{% endfor %}
{% endif %}
<div class="input__form-layout mr-10">
<div class="input bagit-metadata__input mb-10">
<label id="{{ form.field.id_for_label }}-label">{{ form.field.label }}{% if form.field.field.required %} *{% endif %}</label>
{{ form.field }}
</div>

<div class="input-group mb-10">
{{ form.required }}
<label class="checkbox--blue" for="{{ form.required.id_for_label }}">{{ form.required.label }}</label>
</div>

<div class="input-group mb-10">
{{ form.repeatable }}
<label class="checkbox--blue" for="{{ form.repeatable.id_for_label }}">{{ form.repeatable.label }}</label>
</div>
</div>
{% endfor %}
Loading

0 comments on commit f321e03

Please sign in to comment.