Skip to content

Commit 37564b3

Browse files
committed
Merged with master
2 parents 6b97b48 + d41bb88 commit 37564b3

20 files changed

+381
-96
lines changed

core/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
<<<<<<< HEAD
12
"""Django admin interface for core models.
23
"""
34

5+
=======
6+
>>>>>>> FETCH_HEAD
47
from django.contrib import admin
58

69
from core.models import UserProfile

core/models.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
class UserProfile (models.Model):
55
"""Additional information about a User.
66
"""
7+
<<<<<<< HEAD
78
user = models.ForeignKey(User, unique=True)
9+
=======
10+
user = models.ForeignKey(User, unique=True, related_name='profile')
11+
>>>>>>> FETCH_HEAD
812
whitelisted = models.BooleanField()
913
homepage = models.CharField(max_length=100)
1014

media/css/core.css

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ label { display: block; margin-bottom: 4px; font-weight: bold; color: #444; }
107107
.module-list-wrapper { border: 1px solid #bfbfbf; border: 1px solid #bfbfbf; border-bottom: none; }
108108
.module-list .count { float: right; font-size: .9em; color: #aaa; }
109109
.module-item { position: relative; border-bottom: 1px solid #bfbfbf; padding: 10px; }
110+
.module-item p { padding: 0; }
110111

111112
/* module item title */
112113
.module-item .module-item-title { font-weight: bold; font-size: 16px; text-decoration: none; }

projects/admin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
class ProjectAdmin(admin.ModelAdmin):
1111
prepopulated_fields = {'slug': ('name',)}
12-
list_display = ('name', 'repo', 'repo_type', 'theme', 'status', 'whitelisted')
12+
list_display = ('name', 'repo', 'repo_type', 'theme', 'status')
1313
search_fields = ('name', 'repo')
14-
list_filter = ('repo_type', 'whitelisted', 'status')
14+
list_filter = ('repo_type', 'status')
1515

1616

1717
class FileAdmin(admin.ModelAdmin):

projects/fixtures/test_data.json

-48
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,6 @@
175175
"name": "Pinax"
176176
}
177177
},
178-
{
179-
"pk": 18,
180-
"model": "projects.project",
181-
"fields": {
182-
"modified_date": "2010-08-15 13:18:16",
183-
"description": "",
184-
"docs_directory": "",
185-
"project_url": "",
186-
"repo": "http://bitbucket.org/ubernostrum/django-registration",
187-
"version": "0.8",
188-
"user": 1,
189-
"pub_date": "2010-08-15 01:13:37",
190-
"slug": "django-registration",
191-
"name": "Django Registration"
192-
}
193-
},
194178
{
195179
"pk": 2,
196180
"model": "projects.project",
@@ -207,22 +191,6 @@
207191
"name": "Django Test Utils"
208192
}
209193
},
210-
{
211-
"pk": 15,
212-
"model": "projects.project",
213-
"fields": {
214-
"modified_date": "2010-08-15 13:18:15",
215-
"description": "",
216-
"docs_directory": "",
217-
"project_url": "",
218-
"repo": "http://bitbucket.org/tarek/distutils2",
219-
"version": "1.0a1",
220-
"user": 1,
221-
"pub_date": "2010-08-14 23:57:05",
222-
"slug": "distutils2",
223-
"name": "Distutils2"
224-
}
225-
},
226194
{
227195
"pk": 17,
228196
"model": "projects.project",
@@ -238,21 +206,5 @@
238206
"slug": "haystack",
239207
"name": "Haystack"
240208
}
241-
},
242-
{
243-
"pk": 19,
244-
"model": "projects.project",
245-
"fields": {
246-
"modified_date": "2010-08-15 13:18:13",
247-
"description": "ZOMG?!",
248-
"docs_directory": "",
249-
"project_url": "",
250-
"repo": "http://bitbucket.org/mitsuhiko/jinja2-main",
251-
"version": "2.0",
252-
"user": 1,
253-
"pub_date": "2010-08-15 02:13:11",
254-
"slug": "jinja",
255-
"name": "Jinja"
256-
}
257209
}
258210
]

projects/forms.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ def clean_name(self):
1616
potential_slug = slugify(name)
1717
if Project.objects.filter(slug=potential_slug).count():
1818
raise forms.ValidationError('A project with that name exists already!')
19-
19+
2020
return name
2121

2222

2323
class CreateProjectForm(ProjectForm):
2424
class Meta:
2525
model = Project
26-
exclude = ('skip', 'whitelisted', 'user', 'slug', 'repo',
26+
exclude = ('skip', 'user', 'slug', 'repo',
2727
'docs_directory', 'status', 'repo_type')
2828

2929
def save(self, *args, **kwargs):
3030
created = self.instance.pk is None
31-
31+
3232
# save the project
3333
project = super(CreateProjectForm, self).save(*args, **kwargs)
34-
34+
3535
if created:
3636
# create a couple sample files
3737
for i, (sample_file, template) in enumerate(constants.SAMPLE_FILES):
@@ -42,10 +42,10 @@ def save(self, *args, **kwargs):
4242
ordering=i+1,
4343
)
4444
file.create_revision(old_content='', comment='')
45-
45+
4646
# kick off the celery job
4747
update_docs.delay(pk=project.pk)
48-
48+
4949
return project
5050

5151

@@ -54,8 +54,8 @@ class ImportProjectForm(ProjectForm):
5454
help_text='URL for your code (hg or git). Ex. http://github.com/ericholscher/django-kong.git')
5555
class Meta:
5656
model = Project
57-
exclude = ('skip', 'whitelisted', 'theme', 'docs_directory', 'user', 'slug', 'version', 'copyright', 'status')
58-
57+
exclude = ('skip', 'theme', 'docs_directory', 'user', 'slug', 'version', 'copyright', 'status')
58+
5959
def clean_repo(self):
6060
repo = self.cleaned_data.get('repo', '').strip()
6161
if '&&' in repo or '|' in repo:
@@ -70,15 +70,15 @@ def save(self, *args, **kwargs):
7070

7171
# kick off the celery job
7272
update_docs.delay(pk=project.pk)
73-
73+
7474
return project
7575

7676

7777
class FileForm(forms.ModelForm):
7878
content = forms.CharField(widget=forms.Textarea(attrs={'class': 'editor'}),
7979
help_text='<small><a href="http://sphinx.pocoo.org/rest.html">reStructuredText Primer</a></small>')
8080
revision_comment = forms.CharField(max_length=255, required=False)
81-
81+
8282
class Meta:
8383
model = File
8484
exclude = ('project', 'slug', 'status')
@@ -89,28 +89,28 @@ def __init__(self, instance=None, *args, **kwargs):
8989
file_qs = file_qs.exclude(pk=instance.pk)
9090
self.base_fields['parent'].queryset = file_qs
9191
super(FileForm, self).__init__(instance=instance, *args, **kwargs)
92-
92+
9393
def save(self, *args, **kwargs):
9494
# grab the old content before saving
9595
old_content = self.initial.get('content', '')
96-
96+
9797
# save the file object
9898
file_obj = super(FileForm, self).save(*args, **kwargs)
99-
99+
100100
# create a new revision from the old content -> new
101101
file_obj.create_revision(
102102
old_content,
103103
self.cleaned_data.get('revision_comment', '')
104104
)
105105

106106
update_docs.delay(file_obj.project.pk)
107-
107+
108108
return file_obj
109109

110110

111111
class FileRevisionForm(forms.Form):
112112
revision = forms.ModelChoiceField(queryset=None)
113-
113+
114114
def __init__(self, file, *args, **kwargs):
115115
revision_qs = file.revisions.exclude(pk=file.current_revision.pk)
116116
self.base_fields['revision'].queryset = revision_qs
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# encoding: utf-8
2+
import datetime
3+
from south.db import db
4+
from south.v2 import DataMigration
5+
from django.db import models
6+
from projects.models import Project
7+
from core.models import UserProfile
8+
from django.contrib.auth.models import User
9+
from django.core.exceptions import ObjectDoesNotExist
10+
11+
class Migration(DataMigration):
12+
13+
def forwards(self, orm):
14+
"Whitelist any user who has whitelisted projects."
15+
for project in Project.objects.all():
16+
if project.whitelisted:
17+
# If user doesn't have a profile, create one
18+
try:
19+
profile = project.user.get_profile()
20+
except ObjectDoesNotExist:
21+
profile = UserProfile(user=project.user)
22+
# Whitelist the user's profile
23+
profile.whitelisted = True
24+
profile.save()
25+
26+
27+
def backwards(self, orm):
28+
"Whitelist all projects owned by whitelisted users."
29+
for project in Project.objects.all():
30+
# If user doesn't have a profile, skip
31+
# (assume they are not whitelisted)
32+
try:
33+
profile = project.user.get_profile()
34+
except ObjectDoesNotExist:
35+
pass
36+
else:
37+
# Whitelist the user's projects
38+
if profile.whitelisted:
39+
project.whitelisted = True
40+
project.save()
41+
42+
43+
models = {
44+
'auth.group': {
45+
'Meta': {'object_name': 'Group'},
46+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
47+
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
48+
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
49+
},
50+
'auth.permission': {
51+
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
52+
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
53+
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
54+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
55+
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
56+
},
57+
'auth.user': {
58+
'Meta': {'object_name': 'User'},
59+
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
60+
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
61+
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
62+
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
63+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
64+
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
65+
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
66+
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
67+
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
68+
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
69+
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
70+
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
71+
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
72+
},
73+
'contenttypes.contenttype': {
74+
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
75+
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
76+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
77+
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
78+
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
79+
},
80+
'projects.file': {
81+
'Meta': {'ordering': "('denormalized_path',)", 'object_name': 'File'},
82+
'content': ('django.db.models.fields.TextField', [], {}),
83+
'denormalized_path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
84+
'heading': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
85+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
86+
'ordering': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
87+
'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['projects.File']"}),
88+
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'files'", 'to': "orm['projects.Project']"}),
89+
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
90+
'status': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'})
91+
},
92+
'projects.filerevision': {
93+
'Meta': {'ordering': "('-revision_number',)", 'object_name': 'FileRevision'},
94+
'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
95+
'created_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
96+
'diff': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
97+
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'revisions'", 'to': "orm['projects.File']"}),
98+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
99+
'is_reverted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
100+
'revision_number': ('django.db.models.fields.IntegerField', [], {})
101+
},
102+
'projects.importedfile': {
103+
'Meta': {'object_name': 'ImportedFile'},
104+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
105+
'md5': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
106+
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
107+
'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
108+
'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'imported_files'", 'to': "orm['projects.Project']"}),
109+
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'})
110+
},
111+
'projects.project': {
112+
'Meta': {'ordering': "('slug',)", 'object_name': 'Project'},
113+
'copyright': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
114+
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
115+
'docs_directory': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
116+
'extensions': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
117+
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
118+
'modified_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
119+
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
120+
'path': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
121+
'project_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
122+
'pub_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
123+
'repo': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
124+
'repo_type': ('django.db.models.fields.CharField', [], {'default': "'git'", 'max_length': '10'}),
125+
'skip': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
126+
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
127+
'status': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
128+
'suffix': ('django.db.models.fields.CharField', [], {'default': "'.rst'", 'max_length': '10'}),
129+
'theme': ('django.db.models.fields.CharField', [], {'default': "'default'", 'max_length': '20'}),
130+
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects'", 'to': "orm['auth.User']"}),
131+
'version': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'})
132+
}
133+
}
134+
135+
complete_apps = ['projects']

0 commit comments

Comments
 (0)