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

Issue 25 attribution change #48

Draft
wants to merge 24 commits into
base: refactor
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Pycharm stuff
*.idea*
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ All contributors must agree to abide by our [Code of Conduct](https://github.com

## Installation Guide

In order to run this site locally, you'll want to clone this repository and install the requirements:
In order to run this site locally, you'll want to clone this repository and install the requirements (check the [Mac Troubleshooting](#mac-troubleshooting) section if you face any errors):

```
git clone https://github.com/psf/python-in-edu.git
Expand All @@ -18,7 +18,14 @@ source .venv/bin/activate
pip install -r requirements.txt
```

You can then change directories into the python-in-edu folder and run the following command in the terminal:
You can then change directories into the python-in-edu folder and build the database:

```
python manage.py migrate
```


To run the project locally, run the following command in the terminal:

```
python manage.py runserver
Expand All @@ -43,3 +50,28 @@ If you want to use or test email functionality locally, you'll need to [run a si
## Notes

We use the [Spirit project](https://spirit-project.com/) for our forums.

---

<h2 id="mac-troubleshooting">Mac Troubleshooting</h2>

### Postgres

If you don't have an installation of Postgres on your system, you might run into the following error:

```
Error: pg_config executable not found.
```

[Install Postgres](https://postgresapp.com/) to resolve this issue.

### Pillow

If your Pillow installation fails during installing the requirements with the following message:

```
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
```

You can resolve this by installing [jpeg](https://formulae.brew.sh/formula/jpeg) using [homebrew](https://brew.sh/).
3 changes: 3 additions & 0 deletions python-in-edu/mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
}
}

if 'FORCE_HTTPS' in os.environ: # running on heroku
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
Expand Down
174 changes: 171 additions & 3 deletions python-in-edu/resources/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,175 @@
from django.contrib import admin

from .models import Profile, Resource
from .models import (
Profile,
Resource,
Author,
ProfilePopulation,
ProfileRole,
ResourceLanguage,
ResourceUseType,
ResourceAudience,
ResourceType,
SignupChoice,
ResourceStatus,
Device,
Organization
)


admin.site.register(Profile)
admin.site.register(Resource)
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
list_display = [
'user',
'organization',
'country',
'populations',
'psf_member'
]
list_filter = [
'user',
'organization',
'country',
'populations',
'psf_member'
]

@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
list_display = [
'name'
]

@admin.register(ProfilePopulation)
class ProfilePopulationAdmin(admin.ModelAdmin):
list_display = [
'name',
'active',
'underrepresented'
]
list_filter = [
'name',
'active',
'underrepresented'
]

@admin.register(ProfileRole)
class ProfileRoleAdmin(admin.ModelAdmin):
list_display = [
'name',
'active'
]
list_filter = [
'name',
'active'
]


@admin.register(Resource)
class ResourceAdmin(admin.ModelAdmin):
list_display = [
'title',
'submitter',
'status',
'description'
]
list_filter = [
'submitter',
'status'
]

@admin.register(ResourceLanguage)
class ResourceLanguageAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active'
]
list_filter = [
'name',
'active'
]


@admin.register(ResourceUseType)
class ResourceUseTypeAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active'
]
list_filter = [
'active'
]


@admin.register(ResourceAudience)
class ResourceAudienceAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active'
]
list_filter = [
'active'
]


@admin.register(ResourceType)
class ResourceTypeAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active'
]
list_filter = [
'active'
]


@admin.register(SignupChoice)
class SignupChoiceAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active'
]
list_filter = [
'active'
]


@admin.register(ResourceStatus)
class ResourceStatusAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active',
'sequence'
]
list_filter = [
'active'
]


@admin.register(Device)
class DeviceAdmin(admin.ModelAdmin):
list_display = [
'name',
'active'
]
list_filter = [
'active'
]


@admin.register(Organization)
class OrganizationAdmin(admin.ModelAdmin):
list_display = [
'name',
'description',
'active'
]
list_filter = [
'active'
]
91 changes: 0 additions & 91 deletions python-in-edu/resources/choices.py

This file was deleted.

41 changes: 41 additions & 0 deletions python-in-edu/resources/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from django import forms
from .models import Resource, ResourceType, ResourceAudience, Device, ResourceUseType, ResourceLanguage


class CreateResourceForm(forms.ModelForm):
class Meta:
model = Resource
# fields = '__all__'
fields = [
'title',
'description',
'requires_signup',
'license',
]

description = forms.Textarea()

resource_types = forms.ModelMultipleChoiceField(
queryset=ResourceType.objects.all(),
widget=forms.CheckboxSelectMultiple
)

audience = forms.ModelMultipleChoiceField(
queryset=ResourceAudience.objects.all(),
widget=forms.CheckboxSelectMultiple
)

devices = forms.ModelMultipleChoiceField(
queryset=Device.objects.all(),
widget=forms.CheckboxSelectMultiple
)

use_type = forms.ModelMultipleChoiceField(
queryset=ResourceUseType.objects.all(),
widget=forms.CheckboxSelectMultiple
)

languages = forms.ModelMultipleChoiceField(
queryset=ResourceLanguage.objects.all(),
widget=forms.CheckboxSelectMultiple
)
Loading