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

Properly slugify the alias on Project Relationships. #3440

Merged
merged 5 commits into from Dec 21, 2017
Merged

Conversation

@ericholscher
Copy link
Member

@ericholscher ericholscher commented Dec 21, 2017

This includes a migration that will break some URL's.
In the past we haven't slugified aliases,
so this will break URL's for projects in that state.

This shows effected projects:

(<ProjectRelationship: tests-docs -> tests-docs-spanish>, u'/es/latest/', u'eslatest')
(<ProjectRelationship: test_bcn_cn -> test_bcn_cn>, u'/cn', u'cn')
(<ProjectRelationship: recharge_api_calls -> recharge_api_calls>, u'/recharge', u'recharge')
**This includes a migration that will break some URL's**.
In the past we haven't slugified aliases,
so this will break URL's for projects in that state.
@ericholscher
Copy link
Member Author

@ericholscher ericholscher commented Dec 21, 2017

Pared down the initial migration to not change capitalization, and it looks like it does what I want. People will break their own URL's going forward if they try and change their alias.

@ericholscher ericholscher requested a review from humitos Dec 21, 2017
migrations.AlterField(
model_name='project',
name='programming_language',
field=models.CharField(blank=True, choices=[('words', 'Only Words'), ('py', 'Python'), ('js', 'JavaScript'), ('php', 'PHP'), ('ruby', 'Ruby'), ('perl', 'Perl'), ('java', 'Java'), ('go', 'Go'), ('julia', 'Julia'), ('c', 'C'), ('csharp', 'C#'), ('cpp', 'C++'), ('objc', 'Objective-C'), ('other', 'Other')], default='words', help_text='The primary programming language the project is written in.', max_length=20, verbose_name='Programming Language'),
Copy link
Member Author

@ericholscher ericholscher Dec 21, 2017

Above here is just noise from things we've missed I think? I can probably kill it.

Copy link
Member

@humitos humitos left a comment

We are updating the DB here and chaging the CharField for SlugField but we are not touching the logic for new created alias.

Does the SlugField run automatically the slugify on it? (I don't remember clearly) Even if it runs it, it seems that we need our custom one, right?

@@ -52,7 +52,7 @@ class ProjectRelationship(models.Model):
related_name='subprojects')
child = models.ForeignKey('Project', verbose_name=_('Child'),
related_name='superprojects')
alias = models.CharField(_('Alias'), max_length=255, null=True, blank=True)
alias = models.SlugField(_('Alias'), max_length=255, null=True, blank=True)
Copy link
Member

@humitos humitos Dec 21, 2017

I think db_index=False should be added. Since it's True by default for SlugField

@ericholscher
Copy link
Member Author

@ericholscher ericholscher commented Dec 21, 2017

It runs automatically in Django. Django's allow's _, which is fine for this use case.

@ericholscher
Copy link
Member Author

@ericholscher ericholscher commented Dec 21, 2017

screenshot 2017-12-21 15 22 56

@ericholscher ericholscher merged commit 9f4519b into master Dec 21, 2017
1 check passed
@stsewd stsewd deleted the fix-alias-slugify branch Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants