Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #17

Merged
merged 3 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion python-in-edu/resources/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,23 @@ class PopulationChoices(models.TextChoices):
NONE = 'NON', _('None')



class UseTypeChoices(models.TextChoices):
OPEN_SOURCE_PROJECT = 'OSP', _('Open Source Project - accepts contributions')
OPEN_EDUCATION_RESOURCE = 'OER', _('Open Education Resource - ok to distribute and/or revise/remix')
FREE_RESOURCE = 'FRE', _('Free Resource - free to use')
FREEMIUM = 'IUM', _('Freemium - significant portion of resource free to use')
PAID = 'PAI', _('Paid - costs money to access this resource')
UNKOWN = 'UNK', _('Bleh')

class PythonChoices(models.TextChoices):
PYTHON_SPECIFIC = 'PS', _('Python Specific - part or all of resource is Python specific')
LANGUAGE_AGNOSTIC = 'LA', _('Language Agnostic - can be used with any programming language')
UNKNOWN = 'UN',_('Unkown')

class SignUpChoices(models.TextChoices):
CREATE_ACCOUNT = 'CA', _('Must create an account')
PROVIDE_EMAIL = 'PE', _('Must provide email address')
NO_REQUIREMENT = 'NR',_('No sign up requirement')



Expand Down
127 changes: 127 additions & 0 deletions python-in-edu/resources/migrations/0007_auto_20210511_1410.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Generated by Django 3.1.10 on 2021-05-11 14:10

from django.db import migrations, models
import multiselectfield.db.fields


class Migration(migrations.Migration):

dependencies = [
('resources', '0006_resource_status'),
]

operations = [
migrations.RemoveField(
model_name='resource',
name='author_bio',
),
migrations.RemoveField(
model_name='resource',
name='organization',
),
migrations.RemoveField(
model_name='resource',
name='requirements',
),
migrations.RemoveField(
model_name='resource',
name='standards',
),
migrations.RemoveField(
model_name='resource',
name='url',
),
migrations.AddField(
model_name='resource',
name='python_related',
field=models.CharField(choices=[('PS', 'Python Specific - part or all of resource is Python specific'), ('LA', 'Language Agnostic - can be used with any programming language'), ('UN', 'Unkown')], default='UN', help_text='Select the option that best describes this resource.', max_length=2),
),
migrations.AddField(
model_name='resource',
name='url1',
field=models.CharField(default='bleh', help_text='You must link at least one resource.', max_length=200),
preserve_default=False,
),
migrations.AddField(
model_name='resource',
name='url2',
field=models.CharField(blank=True, help_text='Optional additional url related to the same resource', max_length=200, null=True),
),
migrations.AddField(
model_name='resource',
name='url3',
field=models.CharField(blank=True, help_text='Optional additional url related to the same resource', max_length=200, null=True),
),
migrations.AddField(
model_name='resource',
name='url_description1',
field=models.CharField(blank=True, help_text='Use this field, if you are including multiple urls', max_length=50, null=True),
),
migrations.AddField(
model_name='resource',
name='url_description2',
field=models.CharField(blank=True, help_text='Use this field, if you are including multiple urls', max_length=50, null=True),
),
migrations.AddField(
model_name='resource',
name='url_description3',
field=models.CharField(blank=True, help_text='Use this field, if you are including multiple urls', max_length=50, null=True),
),
migrations.AddField(
model_name='resource',
name='use_type',
field=models.CharField(choices=[('OSP', 'Open Source Project - accepts contributions'), ('OER', 'Open Education Resource - ok to distribute and/or revise/remix'), ('FRE', 'Free Resource - free to use'), ('IUM', 'Freemium - significant portion of resource free to use'), ('PAI', 'Paid - costs money to access this resource'), ('UNK', 'Bleh')], default='UN', help_text='Select the use type that best describes this resource.', max_length=3),
),
migrations.AlterField(
model_name='resource',
name='attribution',
field=models.CharField(default='bleh', help_text='What person or organization created this resource?', max_length=250),
preserve_default=False,
),
migrations.AlterField(
model_name='resource',
name='audience',
field=multiselectfield.db.fields.MultiSelectField(choices=[('K12', 'K-12'), ('HIE', 'Higher Education'), ('PFT', 'Professional Training'), ('NSP', 'Not Specific'), ('OTH', 'Other')], help_text="Select 'not specific' for resources for any or all audiences.", max_length=3),
),
migrations.AlterField(
model_name='resource',
name='contact',
field=models.CharField(blank=True, help_text='Not for display, What is the best way to reach you if we have questions about this submission?', max_length=250, null=True),
),
migrations.AlterField(
model_name='resource',
name='description',
field=models.CharField(default='bleh', help_text='Add a description of this resource. (max 500 characters)', max_length=500),
preserve_default=False,
),
migrations.AlterField(
model_name='resource',
name='devices',
field=multiselectfield.db.fields.MultiSelectField(choices=[('DOL', 'Desktop or Laptop Computer'), ('CON', 'Chromebook or Other Netbook'), ('IPD', 'iPad'), ('ATB', 'Android Tablet'), ('IPH', 'iPhone'), ('APH', 'Android Phone'), ('RSP', 'Raspberry Pi'), ('MCC', 'Microcontroller(s)'), ('OTH', 'Other')], help_text='Which devices are compatible with this resource', max_length=3),
),
migrations.AlterField(
model_name='resource',
name='language',
field=models.CharField(blank=True, help_text='What language/s are the written materials available in?', max_length=50, null=True),
),
migrations.AlterField(
model_name='resource',
name='license',
field=models.CharField(blank=True, help_text="What is the copyright license type? Type 'unknown' if the license type is not available.", max_length=200, null=True),
),
migrations.AlterField(
model_name='resource',
name='requires_signup',
field=models.CharField(choices=[('CA', 'Must create an account'), ('PE', 'Must provide email address'), ('NR', 'No sign up requirement')], help_text='Are users required to create an account or provide their email address to access this resource?', max_length=3),
),
migrations.AlterField(
model_name='resource',
name='resource_type',
field=multiselectfield.db.fields.MultiSelectField(choices=[('PA', 'Platform or App'), ('CU', 'Curriculum'), ('TC', 'Tutorial or Course'), ('BK', 'Book'), ('WE', 'Worked Example'), ('DC', 'Documentation'), ('OT', 'Other')], help_text='Select all that apply.', max_length=3),
),
migrations.AlterField(
model_name='resource',
name='title',
field=models.CharField(help_text='What is the name of the resource', max_length=200),
),
]
46 changes: 31 additions & 15 deletions python-in-edu/resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,46 @@ def create_user_profile(sender, instance, created, **kwargs):

# Resource Models

#class Link(models.Model):



class Resource(models.Model):
#Required and optional fields
url1 = models.CharField(max_length=200, help_text="You must link at least one resource.")
url_description1 = models.CharField(max_length=50, blank=True, null=True, help_text="Use this field, if you are including multiple urls")
# resource = models.ForeignKey('Resource', on_delete=models.CASCADE, related_name='links')
url2 = models.CharField(max_length=200, blank=True, null=True, help_text="Optional additional url related to the same resource")
url_description2 = models.CharField(max_length=50, blank=True, null=True, help_text="Use this field, if you are including multiple urls")
# resource = models.ForeignKey('Resource', on_delete=models.CASCADE, related_name='links')
url3 = models.CharField(max_length=200, blank=True, null=True, help_text="Optional additional url related to the same resource")
url_description3 = models.CharField(max_length=50, blank=True, null=True, help_text="Use this field, if you are including multiple urls")
# resource = models.ForeignKey('Resource', on_delete=models.CASCADE, related_name='links')

# core fields
title = models.CharField(max_length=200)
url = models.CharField(max_length=200)
title = models.CharField(max_length=200, help_text="What is the name of the resource")
submitter = models.ForeignKey(User, on_delete=models.CASCADE) # FIXME: probably want to orphan rather than delete
status = models.CharField(max_length=3, choices=choices.ResourceStatusChoices.choices, default=choices.ResourceStatusChoices.PROPOSED)

# required fields
requires_signup = models.BooleanField(default=False)
resource_type = models.CharField(max_length=2, choices=choices.ResourceTypeChoices.choices)
audience = models.CharField(max_length=3, choices=choices.AudienceChoices.choices)
devices = models.CharField(max_length=3, choices=choices.DeviceChoices.choices)
language = models.CharField(max_length=50)
requirements = models.CharField(max_length=200)
license = models.CharField(max_length=200)
requires_signup = models.CharField(max_length=3,choices=choices.SignUpChoices.choices, help_text="Are users required to create an account or provide their email address to access this resource?")
resource_type = MultiSelectField(max_length=30,choices=choices.ResourceTypeChoices.choices, help_text="Select all that apply.")
audience = MultiSelectField(max_length=30,choices=choices.AudienceChoices.choices, help_text="Select 'not specific' for resources for any or all audiences.")
devices = MultiSelectField(max_length=30,choices=choices.DeviceChoices.choices, help_text="Which devices are compatible with this resource")
description = models.CharField(max_length=500, help_text="Add a description of this resource. (max 500 characters)")
attribution = models.CharField(max_length=250, help_text="What person or organization created this resource?")
use_type = models.CharField(max_length=3, choices=choices.UseTypeChoices.choices, help_text="Select the use type that best describes this resource.", default=choices.PythonChoices.UNKNOWN)
python_related = models.CharField(max_length=2, choices=choices.PythonChoices.choices, help_text="Select the option that best describes this resource.", default=choices.PythonChoices.UNKNOWN)

# optional fields
description = models.CharField(max_length=250, blank=True, null=True)
attribution = models.CharField(max_length=250, blank=True, null=True)
author_bio = models.CharField(max_length=250, blank=True, null=True)
organization = models.CharField(max_length=250, blank=True, null=True)
contact = models.CharField(max_length=250, blank=True, null=True)
standards = models.CharField(max_length=250, blank=True, null=True)

#author_bio = models.CharField(max_length=250, blank=True, null=True)
#organization = models.CharField(max_length=250, blank=True, null=True)
contact = models.CharField(max_length=250, blank=True, null=True, help_text="Not for display, What is the best way to reach you if we have questions about this submission?")
#standards = models.CharField(max_length=250, blank=True, null=True)
language = models.CharField(max_length=50, blank=True, null=True, help_text="What language/s are the written materials available in?")
#requirements = models.CharField(max_length=200, blank=True, null=True)
license = models.CharField(max_length=200, blank=True, null=True, help_text="What is the copyright license type? Type 'unknown' if the license type is not available.")

def __str__(self):
return f"{self.title} (submitted by {self.submitter}) - {self.get_status_display()}"
Expand Down
11 changes: 7 additions & 4 deletions python-in-edu/resources/templates/resources/add_resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
<div id="pre_form">

Before we begin, please confirm that the resource you are submitting is
free to use, reproduce and modify, with or without attribution. You will
free to use, reproduce and/or modify, with or without attribution. You will
have an opportunity to specify the license of the resource in just a moment.

<button onclick="showForm()" type="button" class="btn navbar-btn mt-1 d-block">
Yes, the resource is free to use, reproduce and modify
Yes, the resource is free to use, reproduce and/or modify.
</button>
<button onclick="showForm()" type="button" class="btn navbar-btn mt-1 d-block">
No, but I want to submit it so that it can be displayed if paid resources are added in the future.
</button>
<a href="{% url 'resource_list' %}"><button type="button" class="btn mt-1">
No, take me back to the resource list</button></a>
Nevermind, take me back to the resource list</button></a>

</div>

Expand All @@ -42,7 +45,7 @@ <h5>Tell us about the resource</h5>
var optional_fields = document.getElementById('optional_fields');
var optional_fields_button = document.getElementById('optional_fields_button');

console.log(optional_fields_button)
console.log(optional_fields_button)

{% if form.errors %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

<!-- Checkbox (Figuration doesn't have this as a standalone, weirdly? -->
{% if field.field.widget.input_type == "checkbox" %}

{{ field.label_tag }} {{ field }}
{% endif %}

Expand Down
42 changes: 23 additions & 19 deletions python-in-edu/resources/templates/resources/resource_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@
<div class="card-body">
<h4 class="card-title python-blue">{{ object.title }}</h4>
<div class="card-body">

<p>
submitted by <a class="python-link"
href="{% url 'profile_detail' username=object.submitter.username %}">
{{ object.submitter.username }}</a>
</p>
<p>
<a href="{{ object.url }}" class="python-link" target="_blank">get the resource</a>
<p><a href="{{ object.url1 }}" class="python-link" target="_blank">get the resource</a></p>
{% if object.url_description1 %} <p>{{ object.url_description1 }}</p> {% endif %}
{% if object.url2 %}<p>
<a href="{{ object.url2 }}" class="python-link" target="_blank">get the resource</a></p> {% endif %}
{% if object.url_description2 %} <p>{{ object.url_description2 }}</p> {% endif %}
{% if object.url3 %}<p>
<a href="{{ object.url3 }}" class="python-link" target="_blank">get the resource</a></p> {% endif %}
{% if object.url_description3 %} <p>{{ object.url_description3 }}</p> {% endif %}
</p>


{% if request.user == object.submitter %}
<a href="{% url 'resource_update' pk=object.pk %}">
<button type="button" class="btn d-block mt-1 navbar-btn">Edit this resource</button></a>
Expand All @@ -46,12 +48,13 @@ <h4 class="card-title python-blue">{{ object.title }}</h4>

<div class="card">
<div class="card-body">
{% if object.description %} <p><b>Description</b>: {{ object.description }}</p> {% endif %}
{% if object.attribution %} <p><b>Attribution</b>: {{ object.attribution }}</p> {% endif %}
{% if object.author_bio %} <p><b>Author's Bio</b>: {{ object.author_bio }}</p> {% endif %}
{% if object.organization %} <p><b>Contributing Organization</b>: {{ object.organization }}</p> {% endif %}
{% if object.contact %} <p><b>Contact Info</b>: {{ object.contact}}</p> {% endif %}
{% if object.standards %} <p><b>Standards and Certifications</b>: {{ object.standards}}</p> {% endif %}
<p><b>Description</b>: {{ object.description }}</p>
<p><b>Created By</b>: {{ object.attribution }}</p>

<p><small>submitted by <a class="python-link"
href="{% url 'profile_detail' username=object.submitter.username %}">
{{ object.submitter.username }}</a></small></p>
</p>
</div>
</div>

Expand All @@ -61,12 +64,13 @@ <h4 class="card-title python-blue">{{ object.title }}</h4>

<div class="card">
<ul class="list list-spaced list-divided card-list">
<li class="list-item">type of resource: {{ object.get_resource_type_display }}</li>
<li class="list-item">requires signup? {{ object.requires_signup }}</li>
<li class="list-item">audience: {{ object.get_audience_display }}</li>
<li class="list-item">devices: {{ object.get_devices_display }}</li>
<li class="list-item">language: {{ object.language }}</li>
<li class="list-item">requirements: {{ object.requirements }}</li>
<li class="list-item">Type of resource: {{ object.get_resource_type_display }}</li>
<li class="list-item">Audience: {{ object.get_audience_display }}</li>
<li class="list-item">Devices: {{ object.get_devices_display }}</li>
<li class="list-item">Requires signup? {{ object.get_requires_signup_display }}</li>
<li class="list-item">Allowed use: {{ object.get_use_type_display }}</li>
<li class="list-item">Python specific? {{ object.get_python_related_display }}</li>
{% if object.language != None %}<li class="list-item">Language(s) of written material: {{ object.language }}</li>{% endif %}
</ul>
</div>
</div>
Expand Down
25 changes: 14 additions & 11 deletions python-in-edu/resources/templates/resources/resource_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@
{% for field in form %}
{% if field.field.required %}
{% include "resources/field_include.html" with field=field %}
{% endif %}
{% elif not field.field.required %}
{% include "resources/field_include.html" with field=field %}
{% endif %}

{% endfor %}

<!-- Optional fields -->

<button type="button" onclick="showFields()" class="btn my-1" id="optional_fields_button">
Show optional fields</button>
<!--<button type="button" onclick="showFields()" class="btn my-1" id="optional_fields_button">
Show optional fields</button> -->

<span id="optional_fields" style="display: none">
{% for field in form %}
{% if not field.field.required %}
{% include "resources/field_include.html" with field=field %}
{% endif %}
{% endfor %}
</span>
<span id="optional_fields" style="display: none">
{% for field in form %}
{% if not field.field.required %}
{% include "resources/field_include.html" with field=field %}
{% endif %}
{% endfor %}
</span>

<input type="submit" class="btn mt-1 d-block" value="Save" />
<input type="submit" class="btn mt-1 d-block" value="Save" />

</form>