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

don't require twitter #235

Merged
merged 204 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
4a76b50
Create a way to represent a local request.
colons Dec 12, 2022
04c6900
Adopt PEP 673 a little.
colons Dec 12, 2022
d2bc55d
Actually, don't adopt PEP 673 at all.
colons Dec 12, 2022
30cb4d1
Placate flake8.
colons Dec 12, 2022
dd21e70
Create a Profile model for storing nkdsu-specific user information.
colons Dec 12, 2022
a186cf9
Placate mypy.
colons Dec 12, 2022
c0d205d
Fix some version specs in the requirements file.
colons Dec 12, 2022
9b3860b
Update some requirements.
colons Dec 12, 2022
5709eb0
Allow profile display names to be empty.
colons Dec 12, 2022
456f0bb
Make a (currently template-less) profile update view.
colons Dec 12, 2022
729213a
Merge branch 'main' into dont-require-twitter
colons Dec 12, 2022
44faa18
Merge branch 'main' into dont-require-twitter
colons Dec 12, 2022
ad98e10
Reflect changes to the 'folks/' url prefix.
colons Dec 12, 2022
ee778c5
Only test the profile editing form when logged in.
colons Dec 12, 2022
6b5e434
Make a template for the profile update view.
colons Dec 12, 2022
72a5af4
Don't log out before hitting these login-required URLs.
colons Dec 12, 2022
c723a15
Self-close this input tag.
colons Dec 12, 2022
074bd80
Sketch out a form for adding Votes.
colons Dec 16, 2022
6acb38a
Don't manually 404 when someone tries to edit an anonymous profile.
colons Dec 16, 2022
9b9a5b2
Make a page for the vote form to live on.
colons Dec 16, 2022
f479f5c
Placate black, at least a bit.
colons Dec 16, 2022
b37a665
Replace twitter intent links with internal request links.
colons Dec 16, 2022
1b91bbd
Populate the selected track list from the ?t parameter.
colons Dec 16, 2022
bfb4cac
Don't specify an action for the vote form.
colons Dec 16, 2022
c30092e
Constrain and explain the vote 'text' field.
colons Dec 16, 2022
026cb7b
Don't visually imply that you should write an essay against a request.
colons Dec 16, 2022
38b4588
Cover VoteView in the Instant Coverage tests.
colons Dec 16, 2022
4a89143
Give up on using a form field for tracks in requests.
colons Dec 16, 2022
1b361cd
Stop opening the vote form in a new tab.
colons Dec 16, 2022
837a168
Indent the login template.
colons Dec 16, 2022
30399b1
Draft an explanation of what's going on with #235.
colons Dec 16, 2022
416aaa0
Include this new explanation on the login page.
colons Dec 16, 2022
12e7b7e
Link to the "tweet~" tweet specifically.
colons Dec 16, 2022
f427967
Only show TWITTER.md contents when someone's trying to make a request.
colons Dec 16, 2022
74f921e
Restore a link to request music via twitter without logging in.
colons Dec 16, 2022
fbfa817
Fix a typo.
colons Dec 16, 2022
4158858
Don't show form errors more than once on the login page.
colons Dec 16, 2022
d0e3d94
Put some space under blocks of markdown text.
colons Dec 16, 2022
de124b7
Mess less with form error message position.
colons Dec 16, 2022
31e36d5
Collapse some form rules.
colons Dec 16, 2022
fa8110c
Make help text look a bit more normal on p forms.
colons Dec 16, 2022
9b89991
Improve some strings on the request page.
colons Dec 16, 2022
18b49af
Fix the request link in the selection list.
colons Dec 17, 2022
5530f02
Add a reminder to not surface the vote link when a selection is too big.
colons Dec 17, 2022
71f3ce5
Surface what tracks are included in a request on the request page.
colons Dec 17, 2022
d8785a0
Make requesting things manually work.
colons Dec 21, 2022
990ab8b
Send people to their profile page after doing a profile edit.
colons Dec 21, 2022
e59ed1c
Fix avatar uploading.
colons Dec 21, 2022
57be678
Show avatars, unprocessed and unscaled, on profile pages.
colons Dec 21, 2022
8496cfb
Provide tools for people to edit profiles on their own profile page.
colons Dec 21, 2022
0368bbd
Placate black.
colons Dec 21, 2022
b213653
Merge branch 'main' into dont-require-twitter
colons Jan 18, 2023
c0e11dc
Merge branch 'main' into dont-require-twitter
colons Jan 19, 2023
53e39d5
Fix some test URLs.
colons Feb 6, 2023
2f0a803
Placate (newer) black.
colons Feb 6, 2023
0639516
Don't expect the cat's website to work.
colons Feb 6, 2023
545f599
Try to make the login page make sense.
colons Feb 7, 2023
add1aba
Stop hitting the Twitter API on boot.
colons Feb 7, 2023
5ea6d51
Make a registration page that works. Enforce non-duped usernames.
colons Feb 7, 2023
bf25bf2
Fix some words.
colons Feb 7, 2023
5972142
Make .button look right in light and dark mode.
colons Feb 7, 2023
d6cf034
Cover the registration view in tests.
colons Feb 7, 2023
fa8e4ef
Enable atomic requests where possible.
colons Feb 7, 2023
e351e0e
Give people actionable feedback when creating an account.
colons Feb 7, 2023
33ba740
Use a .button on the vote form.
colons Feb 7, 2023
8a08ee4
Surface profile avatars, when they're present, on inline votes.
colons Feb 7, 2023
0952c1e
Stop surfacing broken images on votes.
colons Feb 7, 2023
752d9ae
Include both profile and profile edit links in the footer.
colons Feb 7, 2023
ae31f29
Make the avatar shown on profile pages somewhat consistent.
colons Feb 7, 2023
cc12885
Link to profile pages from votes.
colons Feb 7, 2023
db917af
Placate black.
colons Feb 7, 2023
09e2296
Convert uploaded avatars into 1024x1024 png files.
colons Feb 7, 2023
ec4f69d
Use a smaller avatar size, and abstract it a little.
colons Feb 7, 2023
d428335
Surface some truths on profile pages.
colons Feb 7, 2023
b92628b
Use a shorter, hopefully better URL for new-style user pages.
colons Feb 7, 2023
59aec65
Fix the logic of account linking for existing accounts.
colons Feb 7, 2023
46c2ee1
Include the social_django URLs as a proper Python import.
colons Feb 7, 2023
82fd5db
Provide twitter account disconnection as an option.
colons Feb 7, 2023
08ed0dd
Lay this account information out in a way that makes any sense.
colons Feb 7, 2023
ce9e74b
Start playing with auth pipelines.
colons Feb 7, 2023
57b9440
Fix disconnection.
colons Feb 7, 2023
9bb8ba3
Validate some things about users who are logging in.
colons Feb 7, 2023
e0480de
Make some things about social auth management flow better.
colons Feb 7, 2023
df5f3bf
Explain some auth refusal cases, and lay out one more that is needed.
colons Feb 8, 2023
bc5543b
Note an additional problem.
colons Feb 8, 2023
318c58e
Fix an import and a type check.
colons Feb 8, 2023
5d00d5e
Add another auth todo.
colons Feb 8, 2023
9c51f02
Don't mention adopted requests unless they exist.
colons Feb 8, 2023
f531dcc
Don't 500 when predictable and/or intended auth errors happen.
colons Feb 8, 2023
b39f35f
Add some explicit handling of passwordless users.
colons Feb 8, 2023
bc16c2f
Fix a typo. Change some words.
colons Feb 8, 2023
cc6bde8
Use a styled button on the profile edit form.
colons Feb 8, 2023
6ee6a6c
Let people set a password for the first time.
colons Feb 8, 2023
84a66f8
Stop logging trivia by default.
colons Feb 8, 2023
256765b
Fix* the test build.
colons Feb 8, 2023
7510ca9
(Attempt to) prevent duplicate twitter user association.
colons Feb 8, 2023
8a8c04c
Don't allow reconnections of disconnected accounts.
colons Feb 8, 2023
c94521d
Break up this horrible nested boolean mess.
colons Feb 8, 2023
cfc182f
Be a bit clearer to randos about why they can't log in.
colons Feb 8, 2023
7ba8e6b
Make Elfs, and give them some exclusive prizes.
colons Feb 9, 2023
7eb7105
Delay the creation of ELFS a little.
colons Feb 9, 2023
7817017
Order these views more reasonably.
colons Feb 9, 2023
67d8dac
Don't use Django's stock password change template.
colons Feb 9, 2023
8db39c4
Surface display names for local users.
colons Feb 9, 2023
cf19ab7
Make TwitterUser adoption work.
colons Feb 9, 2023
7d86ff4
Make what I think is a phrasing improvement.
colons Feb 9, 2023
45452fe
Delay the import of `is_elf`.
colons Feb 9, 2023
3c9ba9d
Import avatar and display name from twitter, if appropriate.
colons Feb 9, 2023
b6cde28
Get a higher-resolution avatar.
colons Feb 9, 2023
db14ca9
Reorder these errors so that more relevant ones are thrown first.
colons Feb 9, 2023
a83eada
Show a union of twitter and local requests on new user pages.
colons Feb 9, 2023
b78c949
Show what user you're logged in as in the footer.
colons Feb 9, 2023
0f6b174
Pull the self infobox into a dedicated include. Put it in two places.
colons Feb 9, 2023
aefb1d5
Try to remember this isn't a work thing.
colons Feb 9, 2023
02baf2c
Catch another.
colons Feb 9, 2023
9d8800b
Stop trying to link to the tweets of non-tweet requests.
colons Feb 9, 2023
641240c
Merge branch 'main' into dont-require-twitter
colons Feb 9, 2023
619a98d
Surface nkd.su avatars against TwitterUsers, if we have them.
colons Feb 9, 2023
0620f83
Fix a 500 on TwitterUser pages with no associated nkd.su account.
colons Feb 9, 2023
f71b5d1
Placate black.
colons Feb 9, 2023
f3817b7
Delay this import beyond reason. Explain why.
colons Feb 9, 2023
1e6ea0b
Delay ELFS import as much as possible, by making it its own module.
colons Feb 9, 2023
506d41d
Note some more twitter abandonment plans in the privacy policy.
colons Feb 9, 2023
4d83277
Abstract out the user meta box to make new user pages look alike.
colons Feb 9, 2023
4f2e50b
Use a protocol to make sure Profile and TwitterUser are both Voters.
colons Feb 9, 2023
1554d48
Make Profile properly Voter-compatible.
colons Feb 9, 2023
224730a
Put a proper request list on new-style user pages.
colons Feb 9, 2023
e4a8d0f
Remove an unused import.
colons Feb 9, 2023
336ede5
Redirect away from twitter user pages when it has been adopted.
colons Feb 9, 2023
66278f4
Respect profile-based condemnation when sorting tracks.
colons Feb 9, 2023
217d08d
Let staff condemn local users.
colons Feb 9, 2023
7a3dba1
Placate black.
colons Feb 9, 2023
7867b92
Make sure every user has a profile.
colons Feb 9, 2023
3e324ab
Merge branch 'main' into dont-require-twitter
colons Feb 9, 2023
8a64525
Placate black.
colons Feb 9, 2023
f5db27a
Remove tweet-ingestion machinery.
colons Feb 9, 2023
b1b5c3a
Remove tweepy from the project entirely.
colons Feb 9, 2023
2f232eb
Merge branch 'main' into dont-require-twitter
colons Feb 9, 2023
8d173da
Remove an unused URL.
colons Feb 9, 2023
8195645
Stop surfacing bad trivia.
colons Feb 9, 2023
0fcf28d
Explain what to do when logging in with an adopted twitter account.
colons Feb 9, 2023
b2f177a
Don't imply that signing in with twitter always counts as registration.
colons Feb 9, 2023
8faa71a
Point people to a correctly-named place to disconnect.
colons Feb 9, 2023
e67d3a8
Provide a way to uniquely identify voters. Voter ID, as it were.
colons Feb 9, 2023
77a8188
Fix a RelatedObjectDoesNotExist.
colons Feb 10, 2023
0572c12
Placate black.
colons Feb 10, 2023
14ceee4
Move this mixins into the mixins module.
colons Feb 10, 2023
d7f8145
Require login for library addition requests.
colons Feb 10, 2023
f6329c1
Require authentication for reporting bad metadata, too.
colons Feb 10, 2023
89ed47a
Use our accounts system to manage library amendment requests.
colons Feb 10, 2023
f741f4e
Provide admins a way to post now playing tweets without the API.
colons Feb 10, 2023
a476192
Remove vote-related intent URL machinery.
colons Feb 10, 2023
6a725ce
Restrict the number of tracks that can be associated with a vote.
colons Feb 10, 2023
b5d58ed
Remove a todo that has been addressed.
colons Feb 10, 2023
befbbf6
Remove twitter-facing metadata.
colons Feb 10, 2023
e3ad2a8
Clear selection when submitting a request.
colons Feb 10, 2023
19d0af8
Steal track filtering from our now-gone tweet ingestion method.
colons Feb 10, 2023
2f75f62
Make fewer Show queries.
colons Feb 10, 2023
4bde053
Handle zero-eligibility request attempts.
colons Feb 10, 2023
1494dbe
Don't let people select tracks they already requested.
colons Feb 10, 2023
9f81b6d
Don't show a plus button on tracks you've already voted for.
colons Feb 10, 2023
1781a83
Note #245 in a formerly-XXX comment.
colons Feb 10, 2023
fe430d8
Placate black.
colons Feb 10, 2023
a33c79c
Enforce some password strength requirements.
colons Feb 10, 2023
cc7346e
Fix some CSS mistargeting. This might still be catching false positives.
colons Feb 10, 2023
f28ccb2
Unify voter implementations for the purpose of stats generation.
colons Feb 10, 2023
18bea96
Remove a print from a migration.
colons Feb 10, 2023
8044fd7
Remove some unused imports.
colons Feb 10, 2023
eee1816
Fix some NameErrors in stats generation.
colons Feb 10, 2023
fb41bac
Show the request button against all eligible tracks to anonymous users.
colons Feb 10, 2023
5edce19
This is no longer a matter of taste.
colons Feb 10, 2023
bb5df55
Provide some reassurance that you have, in fact, changed your password.
colons Feb 10, 2023
6a0e606
Save bad metadata requests when they are submitted.
colons Feb 10, 2023
aed56e9
Fix user links on the requests list.
colons Feb 10, 2023
ee17f4f
Be consistent about how we read 'user' in the track include.
colons Feb 10, 2023
574d2a8
Fix surfacing of votes on user pages.
colons Feb 10, 2023
9e1a648
Fix redirection after performing destructive admin actions.
colons Feb 10, 2023
f70f150
Placate some linters, including myself.
colons Feb 10, 2023
59e4377
Remove an instance of the now-removed "successful" field.
colons Feb 10, 2023
50d4af9
Remove a pointless empty section.
colons Feb 10, 2023
17727f7
Stop letting Django generate invalid HTML for us.
colons Feb 10, 2023
75aacd1
Override the clearable file field template to be exactly the same.
colons Feb 10, 2023
089f3b6
Try to make the file field a bit more reasonable.
colons Feb 10, 2023
3585bb3
Fix our test URL lists.
colons Feb 10, 2023
89a0b33
Provide a profile for looking at in tests.
colons Feb 10, 2023
ffcea12
Expect the cat's backup website to work.
colons Feb 10, 2023
1a51838
Cache tracks with a key including per-user eligibility.
colons Feb 10, 2023
b4de2da
Cache Show.current() for two whole seconds.
colons Feb 10, 2023
fbd0d78
Catch another 'thisisthecat.com'.
colons Feb 10, 2023
1a98fb3
Move the profile creation signal so that it's an addressable function.
colons Feb 10, 2023
714f240
Test the whole site as staff.
colons Feb 10, 2023
953ae1f
Make an everything test for elfs. Fix the non-staff tests.
colons Feb 10, 2023
993bbc2
Stop mentioning twitter in the README.
colons Feb 10, 2023
8fd41d4
Give up completely on making the Elfs group at startup.
colons Feb 10, 2023
ef1f083
Fix an elfs-related import.
colons Feb 10, 2023
0a913ad
Don't worry about delaying is_elf importing any more.
colons Feb 10, 2023
9d0038e
Be very explicit about why we're asking people to disconnect.
colons Feb 10, 2023
dbdba6f
Add a missing comma.
colons Feb 10, 2023
d65908a
Use shorter sentences.
colons Feb 10, 2023
ba7d738
Explain why we recommend signing in with twitter in the first place.
colons Feb 10, 2023
49b960a
Stop mixing and matching 'logged in' and 'signed in'.
colons Feb 10, 2023
993e0e9
Break up this run-on sentence a bit.
euricaeris Feb 10, 2023
f501726
add placeholder icons
homsar Feb 10, 2023
08d21df
Adopt these new placeholder avatars.
colons Feb 10, 2023
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
1 change: 0 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ that's broken, [file a bug][new_issue].
[eg_latest_week]: https://nkd.su/api/week/
[eg_week]: https://nkd.su/api/week/2013-01-05/
[eg_search]: https://nkd.su/api/search/?q=character%20song
[pester]: https://twitter.com/intent/tweet?text=%40mftb
5 changes: 4 additions & 1 deletion PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ This can include:
- a [hashed][django-password-storage] password
- a screen name and a display name
- an avatar
- an email address

[django-password-storage]: https://docs.djangoproject.com/en/3.2/topics/auth/passwords/#how-django-stores-passwords "how Django stores passwords"

Expand All @@ -71,7 +72,9 @@ These will be used to:

You can change your names or avatar at any time. Please contact an admin if you
would like to have this information modified or deleted in a way that the
website doesn't give you controls for.
website doesn't give you controls for. Early in the migration away from
Twitter, less of this will be user-modifiable than we would like, but we'll be
working to sort that quickly.

### sessions

Expand Down
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,31 @@
radio show currently broadcast on [The Cat].

[nkd.su]: https://nkd.su
[The Cat]: https://thisisthecat.com
[The Cat]: https://thecat1079.co.uk
[Neko Desu]: https://nekodesu.radio

### How do I make a request?

If there are any tracks on the front page you would like to request, click on
the ‘+’ next to the current requests and send the generated tweet. If nothing
on the front page strikes your fancy, feel free to use the search box to find
something more your style. Once you've found something, click the + button. If
you can't find what you're looking for, fill out the [request an addition]
form.
the ‘+’ next to the existing requests. If you're signed in, you'll be taken to
a page where you can see what you're requesting and, if you like, add an
optional accompanying message.

You can personalise your request with a message that will appear when people
hover over your user icon. All text that is not either a valid track URL or the
[@nkdsu] mention at the start of the tweet will be displayed.
If you're _not_ signed in, you'll have to follow the instructions on the login
page to set up an appropriate account before you can make requests. Sorry that
the login page is so busy; if you're new here, you can just head straight for
the 'new nkd.su visitors' form.

If you have javascript enabled, you can select tracks so that you can request
several at once by clicking anywhere in a track box that is not a link.
If nothing on the front page strikes your fancy, feel free to use the search
box to find something more your style. Once you've found something, click the +
button. If you can't find what you're looking for and would like to get it
added to the library, you can fill out the [request an addition] form.

None of your Twitter followers will see your request in their timelines unless
they're also following [@nkdsu].
If you have javascript enabled, you can select multiple tracks to request them
at the same time. You can do this by clicking anywhere in a track box that is
not a link.

[request an addition]: https://nkd.su/request
[@nkdsu]: https://twitter.com/nkdsu

### All this is well and good but I don't like Twitter.

Yeah, I get it. In that case, just send Peter an [email] or a text or
something.

[email]: mailto:[email protected]

## How does it work?

Expand Down
18 changes: 18 additions & 0 deletions TWITTER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
It's no longer possible for nkd.su to require the use of Twitter, so we're
migrating to a local account system for making requests.

**If you're an existing nkd.su requester**, you should register using your
Twitter account to inherit your existing request history. You'll be able to
create a password for logging in and disassociate your Twitter account; we just
want to provide continuity.

**If you're new here**, you can make a local-only account from scratch.

Either way, there are some things you should know:

- Newly-created accounts can not use usernames that match the handle of any
Twitter user who has requested things in the past.
- The [privacy policy] is still worth reading.

[@nkdsu]: https://twitter.com/nkdsu/status/744237593164980224
[privacy policy]: https://nkd.su/info/privacy/
3 changes: 3 additions & 0 deletions nkdsu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .monkey import patch

patch()
4 changes: 2 additions & 2 deletions nkdsu/apps/vote/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class DiscardShortlistAdmin(admin.ModelAdmin):


class RequestAdmin(admin.ModelAdmin):
list_display = ('created', 'successful')
list_filter = ('successful',)
list_display = ('created', 'filled_by', 'claimant', 'submitted_by')
list_filter = ('filled_by', 'claimant', 'submitted_by')


class NoteAdmin(admin.ModelAdmin):
Expand Down
12 changes: 12 additions & 0 deletions nkdsu/apps/vote/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.apps import AppConfig
from django.db.models.signals import post_migrate, post_save


class VoteConfig(AppConfig):
name = 'nkdsu.apps.vote'

def ready(self) -> None:
from . import signals

post_save.connect(signals.create_profile_on_user_creation)
post_migrate.connect(signals.make_elfs)
10 changes: 10 additions & 0 deletions nkdsu/apps/vote/elfs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib.auth.models import AnonymousUser, User


ELFS_NAME = "Elfs"


def is_elf(user: User | AnonymousUser) -> bool:
return user.is_authenticated and (
user.is_staff or user.groups.filter(name=ELFS_NAME).exists()
)
15 changes: 14 additions & 1 deletion nkdsu/apps/vote/fixtures/vote.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@
"pk": 1,
"model": "vote.request",
"fields": {
"successful": true,
"blob": "{\"trivia\": \"borderlands\", \"trivia_question\": \"We have always treaded ____\", \"details\": \"Should be \\\"THE iDOLM@STER\\\" - there is no \\\"the\\\" at the moment.\", \"contact\": \"\"}",
"created": "2014-01-05T23:30:04.751Z"
}
Expand Down Expand Up @@ -392,5 +391,19 @@
"public": true,
"show": 79
}
},
{
"pk": 43,
"model": "auth.user",
"fields": {
"username": "someone"
}
},
{
"pk": 45,
"model": "vote.profile",
"fields": {
"user": 43
}
}
]
78 changes: 34 additions & 44 deletions nkdsu/apps/vote/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
from typing import Any, Optional

from django import forms
from django.core.validators import validate_email
from django.utils.safestring import mark_safe
import tweepy

from .models import Note, Request
from .utils import reading_tw_api
from .models import Note, Track, Vote
from ..vote import trivia

_disable_autocorrect = {
Expand All @@ -22,24 +19,15 @@
)


def email_or_twitter(address: str) -> None:
try:
validate_email(address)
except forms.ValidationError:
try:
reading_tw_api.get_user(screen_name=address.lstrip('@'))
except tweepy.TweepError:
raise forms.ValidationError(
'Enter a valid email address or twitter username'
)

class ClearableFileInput(forms.widgets.ClearableFileInput):
"""
The stock clearable file widget generates HTML that cannot be easily laid
out in a reasonable way with CSS. In particular, the way the 'clear'
checkbox is not put in any kind of elements makes intentional layout
basically impossible. Here, we aim to fix that.
"""

class EmailOrTwitterField(forms.EmailField):
widget = forms.TextInput(attrs=dict(_disable_autocorrect, autocapitalize="off"))
default_error_messages = {
'invalid': u'Enter a valid email address or Twitter username',
}
default_validators = [email_or_twitter]
template_name = 'widgets/clearable_file_input.html'


class SearchForm(forms.Form):
Expand All @@ -53,7 +41,6 @@ class TriviaForm(forms.Form):

trivia_question = forms.CharField(widget=forms.HiddenInput)
trivia = forms.CharField(required=False)
track = None

def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
Expand All @@ -75,13 +62,6 @@ def clean_trivia(self):
re.I,
)

request = Request()
request.successful = bool(human)
if self.track:
request.track_id = self.track.pk
request.serialise(self.cleaned_data)
request.save()

if not human:
hint = (
"That's not right, sorry. There are hints <a href='https://"
Expand All @@ -97,18 +77,22 @@ def clean_trivia(self):
return self.cleaned_data['trivia']


class BadMetadataForm(TriviaForm):
class BadMetadataForm(forms.Form):
details = forms.CharField(
widget=forms.Textarea, label="What needs fixing?", required=False
)
contact = EmailOrTwitterField(label="Email/Twitter (not required)", required=False)
track: Track

def __init__(self, *args, **kwargs) -> None:
self.track = kwargs.pop('track')
def __init__(self, *args, track: Track, **kwargs) -> None:
self.track = track
super().__init__(*args, **kwargs)


class RequestForm(TriviaForm):
class RequestForm(forms.Form):
"""
A form for requesting that a track be added to the library.
"""

title = forms.CharField(widget=_proper_noun_textinput, required=False)
artist = forms.CharField(widget=_proper_noun_textinput, required=False)
show = forms.CharField(
Expand All @@ -120,29 +104,35 @@ class RequestForm(TriviaForm):
label="Additional Details",
required=False,
)
contact = EmailOrTwitterField(label="Email Address/Twitter name", required=True)

def clean(self) -> Optional[dict[str, Any]]:
cleaned_data = super().clean()
if cleaned_data is None:
return None

compulsory = Request.METADATA_KEYS

filled = [
cleaned_data[f]
for f in cleaned_data
if f not in compulsory and cleaned_data[f]
]
filled = [cleaned_data[f] for f in cleaned_data if cleaned_data[f]]

if len(filled) < 2:
if len(filled) < 1:
raise forms.ValidationError(
"I'm sure you can give us more information than that."
'please provide at least some information to work with'
)

return cleaned_data


class VoteForm(forms.ModelForm):
"""
A form for creating a :class:`.models.Vote`.
"""

class Meta:
model = Vote
fields = ['text']
widgets = {
'text': forms.TextInput(),
}


class CheckMetadataForm(forms.Form):
id3_title = forms.CharField(required=False, widget=forms.Textarea())
id3_artist = forms.CharField(required=False, widget=forms.Textarea())
Expand Down
26 changes: 0 additions & 26 deletions nkdsu/apps/vote/management/commands/get_votes_from_user.py

This file was deleted.

25 changes: 0 additions & 25 deletions nkdsu/apps/vote/management/commands/listen_for_votes.py

This file was deleted.

20 changes: 0 additions & 20 deletions nkdsu/apps/vote/management/commands/refresh_votes.py

This file was deleted.

Loading