-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add Domain model to track project Domains #1575
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
ef05c6a
Add Domain model
ericholscher eba84ea
Add Admin views for Domains
ericholscher 86d416c
Add API endpoint for domains
ericholscher 27fb6b3
Add domain templates
ericholscher 09ecf2d
Add Domain tracking to middleware & test it
ericholscher dc59895
Fix linting errors
ericholscher 8aa257f
Clean up domain admin a bit
ericholscher 3669f48
Clean up tests
ericholscher d1e7a6f
Add nicer UX and check for only 1 active canonical model
ericholscher 6b6eaa2
Add data migration
ericholscher 0c66e47
Add Domain inline for Project admin
ericholscher bcfe13a
Remove canonical_url usage in Project forms
ericholscher 318457d
Use Domain objects for CNAME symlinking
ericholscher cec9706
Add tests for symlinking code
ericholscher a594e63
Make domains nicely cleaned before save
ericholscher 9991b77
Add domain model tests
ericholscher da2c644
Clean up a bit of the modeling & use basic count
ericholscher a9e512f
Fix tests & logic
ericholscher 78e8497
Use Domain modeling for canonical setup
ericholscher 0d9a5c9
Clean up symlinking and symlink testing
ericholscher add1507
Clean up canonical tests for new scheme
ericholscher 5620889
Remove active concept, and just have folks delete ones they don’t want.
ericholscher cb7d4c6
Add basic test case for API, to verify it doesn’t break
ericholscher 116f18b
Clean up domain tests more
ericholscher 51f42da
Clean up domain forms
ericholscher 70ea09d
Clean up views and make sure they are login required
ericholscher 80bf3dd
Merge remote-tracking branch 'origin/master' into add-domain-model
ericholscher e3001b3
Merge remote-tracking branch 'origin/master' into add-domain-model
ericholscher 3da467b
Fix comments and merge fail
ericholscher 9e1a62f
Fix migrations
ericholscher cc0c23f
Kill copypasta
ericholscher f49ebd2
Fix template logic
ericholscher b93cd05
Fix import and linting
ericholscher 8ca4056
Post to random channel to reduce noise
ericholscher c23f3a1
Fix build serializer
ericholscher 155823b
Delete merge flail
ericholscher b15d0c2
Clean up copypasta fail
ericholscher 6528527
Fix quotes
ericholscher a548d60
Kill unused JS in templates
ericholscher 227d5a3
Clean up project injection on the Domain form
ericholscher 0075362
Fix logic around Create/Delete of domains
ericholscher 6cb9d9d
CLean up more templates
ericholscher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
''' | ||
""" | ||
Common mixin classes for views | ||
''' | ||
""" | ||
|
||
from django.conf import settings | ||
|
||
from vanilla import ListView | ||
|
||
|
||
class StripeMixin(object): | ||
'''Adds Stripe publishable key to the context data''' | ||
|
||
"""Adds Stripe publishable key to the context data""" | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(StripeMixin, self).get_context_data(**kwargs) | ||
context.update({ | ||
'publishable': settings.STRIPE_PUBLISHABLE, | ||
}) | ||
return context | ||
|
||
|
||
class ListViewWithForm(ListView): | ||
|
||
"""List view that also exposes a create form""" | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(ListViewWithForm, self).get_context_data(**kwargs) | ||
context['form'] = self.get_form(data=None, files=None) | ||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('projects', '0005_sync_project_model'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Domain', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('url', models.URLField(unique=True, verbose_name='URL')), | ||
('machine', models.BooleanField(default=False, help_text='This URL was auto-created')), | ||
('cname', models.BooleanField(default=False, help_text='This URL is a CNAME for the project')), | ||
('canonical', models.BooleanField(default=False, help_text='This URL is the primary one where the documentation is served from.')), | ||
('count', models.IntegerField(default=0, help_text='Number of times this domain has been hit.')), | ||
('project', models.ForeignKey(related_name='domains', to='projects.Project')), | ||
], | ||
options={ | ||
'ordering': ('-canonical', '-machine', 'url'), | ||
}, | ||
), | ||
] |
26 changes: 26 additions & 0 deletions
26
readthedocs/projects/migrations/0007_migrate_canonical_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
def migrate_canonical(apps, schema_editor): | ||
Project = apps.get_model("projects", "Project") | ||
for project in Project.objects.all(): | ||
if project.canonical_url: | ||
domain = project.domains.create( | ||
url=project.canonical_url, | ||
canonical=True, | ||
) | ||
print "Added {url} to {project}".format(url=domain.url, project=project.name) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('projects', '0006_add_domain_models'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_canonical) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to prefix boolean attributes/field names with
is_
, e.g.is_canonical
which makes it clear what to expect from field and is better for reading expressions likedomain.is_cname
.We don't follow that practice in the rest of the project, but maybe here is a good place to start with it?