annotate apps/profile/models.py @ 151:c7be7def8b57

Bundles! (basic functionality) Changes made in this commit: * Added new dependencies (see pip-requirements) * Added new dependency and setup information to README * Deleted the included mptt app (in apps/mptt) in favour of just adding the dependency to pip-requirements (makes it easier to update, etc) * Changed the import convention to use `from apps.bundle.models import Bundle` rather than `from agora.apps.bundle.models import Bundle` because Celery was having problems with the latter style. Everything should still work. * Moved the syntax-highlighting and related code for snippets into separate HTML files so that they can be used by the bundle app And, of course, the ability to upload bundles. But wait! There's more! Changes still to come, for only $19.95 a month: * Bundle versioning * Automatic license integration (i.e. adding headers to files) * The ability to download bundles (zip, tar, etc) * Rating bundles * And much, much more! Batteries not included.
author dellsystem <ilostwaldo@gmail.com>
date Mon, 15 Oct 2012 00:52:00 -0400
parents 5ab229c9d348
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
1 from django.db import models
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
2 from django.contrib.auth.models import User
130
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
3 from django.utils.translation import ugettext as _
91
8ef0a2a03034 Add some blank lines where relevant
dellsystem <ilostwaldo@gmail.com>
parents: 29
diff changeset
4
151
c7be7def8b57 Bundles! (basic functionality)
dellsystem <ilostwaldo@gmail.com>
parents: 130
diff changeset
5 from apps.free_license.models import FreeLicense
c7be7def8b57 Bundles! (basic functionality)
dellsystem <ilostwaldo@gmail.com>
parents: 130
diff changeset
6 from apps.pygments_style.models import PygmentsStyle
29
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
7
91
8ef0a2a03034 Add some blank lines where relevant
dellsystem <ilostwaldo@gmail.com>
parents: 29
diff changeset
8
29
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
9 class Profile(models.Model):
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
10 user = models.OneToOneField(User)
130
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
11 preferred_license = models.ForeignKey(FreeLicense, help_text=_("\
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
12 By default, all of your submissions will be under the following \
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
13 license, and this license will be displayed next to your \
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
14 submissions. <a href=\"/licenses/\">Find out more.</a>"),
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
15 default=1)
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
16 interests = models.CharField(max_length=512, null=True, help_text=_("\
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
17 Tell us about your research interests (e.g. \
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
18 <em>signal processing</em>, <em>hyperbolic PDEs</em>). These \
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
19 keywords will be used when searching for submissions."), blank=True,
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
20 verbose_name=_("Research interests"))
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
21 blurb = models.TextField(max_length=16384, null=True, help_text=_("\
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
22 Finally, anything else you would like to say about yourself."),
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
23 blank=True)
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
24 pygments_style = models.ForeignKey(PygmentsStyle, default=1,
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
25 verbose_name=_('Syntax highlighting style'), help_text=_("\
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
26 Choose a stylesheet for displayed syntax-highlighted code. Most of \
5ab229c9d348 Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents: 102
diff changeset
27 these stylesheets are based off of default Pygments stylesheets."))
29
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
28
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
29 def __unicode__(self):
6ba969517b9c Implement initial profiles, cleanup models, change Free_license to FreeLicense
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
diff changeset
30 return self.user.username
102
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
31
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
32
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
33 # Defines a post_save hook to ensure that a profile is created for each user
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
34 # This also ensures that the admin user (created when running syncdb) has one
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
35 def create_user_profile(sender, instance, created, **kwards):
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
36 if created:
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
37 Profile.objects.create(user=instance)
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
38
f872c643b056 Updates to snippet functionality (see details)
dellsystem <ilostwaldo@gmail.com>
parents: 91
diff changeset
39 models.signals.post_save.connect(create_user_profile, sender=User)