Permalink
Browse files

follow pep8 documentation guidelines

  • Loading branch information...
Justine Tunney
Justine Tunney committed Nov 25, 2011
1 parent becd060 commit 993931507e125e7f8d698cacb62be4a230960f1e
View
@@ -76,8 +76,7 @@ def _too_many_caps(text):
def forumlinks(after, count, **kwargs):
- """Used for continuous stream of forum post links
- """
+ """Used for continuous stream of forum post links"""
after, count = int(after), int(count)
if after < 0 or count <= 0:
raise APIException(_("bad arguments"))
@@ -91,8 +90,7 @@ def forumlinks(after, count, **kwargs):
def attendees(bounds, **kwargs):
- """Find all people going who live within visible map area.
- """
+ """Find all people going who live within visible map area"""
if bounds:
bbox = _str_to_bbox(bounds)
qset = (db.UserInfo.objects
@@ -110,8 +108,7 @@ def attendees(bounds, **kwargs):
def rides(bounds=None, **kwargs):
- """Find all rides within visible map area.
- """
+ """Find all rides within visible map area"""
if bounds:
bbox = _str_to_bbox(bounds)
qset = (db.Ride.objects
@@ -142,8 +139,7 @@ def ride_request_update(request_id, status, user=None, **kwargs):
def attendee_info(username, **kwargs):
- """Get information for displaying attendee bubble
- """
+ """Get information for displaying attendee bubble"""
user = (db.User.objects
.select_related("userinfo")
.get(username=username))
@@ -158,8 +154,7 @@ def attendee_info(username, **kwargs):
def _check_post(user, post):
- """Ensure user-submitted forum content is kosher
- """
+ """Ensure user-submitted forum content is kosher"""
if user.is_staff:
return
if len(post.content) < 3:
@@ -299,8 +294,7 @@ def article_delete(user, article_slug, **kwargs):
def article_remove(user, article_slug, action, **kwargs):
- """Makes an article unlisted and invisible to search engines
- """
+ """Makes an article unlisted and invisible to search engines"""
if not (user and user.id):
raise APIException(_("you're not logged in"))
if not user.is_staff:
@@ -320,8 +314,7 @@ def article_remove(user, article_slug, action, **kwargs):
def article_get(user, article_slug=None, **kwargs):
- """Get article information
- """
+ """Get article information"""
try:
article = db.Article.objects.get(slug=article_slug, is_deleted=False)
except db.Article.DoesNotExist:
@@ -331,9 +324,9 @@ def article_get(user, article_slug=None, **kwargs):
'user': user})
return [article.as_dict({'html': html})]
+
def article_get_comments(user, article_slug=None, **kwargs):
- """Get all comments for an article
- """
+ """Get all comments for an article"""
try:
article = db.Article.objects.get(slug=article_slug, is_deleted=False)
comments = article.comment_set.all()
@@ -418,8 +411,7 @@ def comment_depth(id):
def comment_get(user, comment_id=None, **kwargs):
- """Fetch a single comment information
- """
+ """Fetch a single comment information"""
try:
comment = db.Comment.objects.get(id=comment_id, is_deleted=False)
except db.Comment.DoesNotExist:
@@ -444,8 +436,7 @@ def comment_get(user, comment_id=None, **kwargs):
def comment_edit(user, comment_id, content, **kwargs):
- """Edit a comment's content
- """
+ """Edit a comment's content"""
if not (user and user.id):
raise APIException(_("you're not logged in"))
content = content.strip()
@@ -465,8 +456,7 @@ def comment_edit(user, comment_id, content, **kwargs):
def comment_remove(user, comment_id, action, **kwargs):
- """Allows moderator to remove a comment
- """
+ """Allows moderator to remove a comment"""
if not (user and user.id):
raise APIException(_("you're not logged in"))
if not user.is_staff:
@@ -542,20 +532,17 @@ def comment_vote(user, comment, vote, **kwargs):
def comment_upvote(user, comment, **kwargs):
- """Upvotes a comment
- """
+ """Upvotes a comment"""
return comment_vote(user, comment, "up", **kwargs)
def comment_downvote(user, comment, **kwargs):
- """Downvotes a comment
- """
+ """Downvotes a comment"""
return comment_vote(user, comment, "down", **kwargs)
def message_send(user, to_username, content, **kwargs):
- """Send a private message.
- """
+ """Send a private message"""
if not (user and user.id):
raise APIException(_("you're not logged in"))
content = content.strip()
@@ -603,8 +590,7 @@ def message_delete(user, message_id, **kwargs):
def check_username(username, check_if_taken=True, **kwargs):
- """Check if a username is valid and available
- """
+ """Check if a username is valid and available"""
if len(username) < 3:
raise APIException(_("username too short"))
if len(username) > 30:
@@ -652,8 +638,7 @@ def signup(request, username, password, email, **kwargs):
def login(request, username, password, **kwargs):
- """Login user
- """
+ """Login user"""
if request.user.is_authenticated():
raise APIException(_("you're already logged in"))
user = auth.authenticate(username=username, password=password)
@@ -664,7 +649,6 @@ def login(request, username, password, **kwargs):
def logout(request, **kwargs):
- """Logout user
- """
+ """Logout user"""
auth.logout(request)
return []
View
@@ -24,5 +24,6 @@ def clean(self, values):
check_captcha = captcha.submit(recaptcha_challenge_value,
recaptcha_response_value, settings.RECAPTCHA_PRIVATE_KEY, {})
if not check_captcha.is_valid:
- raise forms.util.ValidationError(self.error_messages['captcha_invalid'])
+ raise forms.util.ValidationError(
+ self.error_messages['captcha_invalid'])
return values[0]
View
@@ -88,8 +88,7 @@ def geocode(address):
def address_to_latlng(address):
- """Shortcut function to just get lat/lng from geocode()
- """
+ """Shortcut function to just get lat/lng from geocode()"""
results = geocode(address)
if not results:
return None, None
@@ -99,8 +98,7 @@ def address_to_latlng(address):
def haversine(lat1, lng1, lat2, lng2):
- """Calculate kilometer distance between two places on earth
- """
+ """Calculate kilometer distance between two places on earth"""
# convert to radians
lng1 = float(lng1) * pi / 180
lng2 = float(lng2) * pi / 180
View
@@ -118,8 +118,7 @@ def save(self):
class UserInfo(models.Model):
- """Extra DB information to associate with a Django auth user
- """
+ """Extra DB information to associate with a Django auth user"""
ATTENDANCE_CHOICES = (
('yes', 'Yes'),
('no', 'No'),
@@ -313,17 +312,15 @@ def __unicode__(self):
@models.permalink
def get_absolute_url(self):
- """Returns absolute canonical path for article
- """
+ """Returns absolute canonical path for article"""
if self.is_forum:
return ('forum-post', [self.slug])
else:
return ('article', [self.slug])
@models.permalink
def get_forum_url(self):
- """Returns non-canonical url to view article on forum
- """
+ """Returns non-canonical url to view article on forum"""
return ('forum-post', [self.slug])
def delete(self):
@@ -431,8 +428,7 @@ def get_query_set(self):
class NewsArticle(Article):
- """View of Article table that doesn't show forum posts
- """
+ """View of Article table that doesn't show forum posts"""
objects = NewsArticleManager()
class Meta:
@@ -452,8 +448,7 @@ def get_query_set(self):
class ForumPost(Article):
- """View of Article table that doesn't news articles
- """
+ """View of Article table that doesn't news articles"""
objects = ForumPostManager()
class Meta:
@@ -467,8 +462,7 @@ def save(self, *args, **kwargs):
class Comment(models.Model):
- """Users can leave comments on articles reddit style
- """
+ """Users can leave comments on articles reddit style"""
article = models.ForeignKey(Article, editable=False, help_text="""
The article to which this comment belongs.""")
user = models.ForeignKey(User, null=True, blank=True, editable=False,
@@ -610,8 +604,7 @@ def prune(days_old=30):
class Message(models.Model):
- """One user sending a message to another.
- """
+ """One user sending a message to another"""
from_user = models.ForeignKey(User, editable=False,
related_name="messages_sent", help_text="""
The user who sent the message.""")
@@ -678,8 +671,7 @@ def is_spam(msg):
class Ride(models.Model):
- """Info about a person or bus driving to Event for carpooling
- """
+ """Info about a person or bus driving to Event for carpooling"""
RIDETYPE_CHOICES = (
('car', 'Car'),
('bus', 'Bus'),
@@ -79,8 +79,7 @@ def timesince_short(timestamp):
@register.filter
def synopsis(text, max_words=10, max_chars=40):
- """
- Creates a shortened version of content
+ """Creates a shortened version of content
We only care about the first line. If the text begins with a
markdown quotation, it will be excluded unless the whole thing is
@@ -100,8 +99,7 @@ def synopsis(text, max_words=10, max_chars=40):
def mortify(text, url, funk):
- """
- Extracts specified synopsis in markdown article
+ """Extracts specified synopsis in markdown article
There are two ways to specify a synopsis:
@@ -146,8 +144,7 @@ def _markup(text, transform):
@register.filter
def markup(text):
- """Runs text through markdown, no html allowed
- """
+ """Runs text through markdown, no html allowed"""
return _markup(text, markdown_safe.convert)
markup.is_safe = True
@@ -162,17 +159,14 @@ def strip_annoying_html(html):
@register.filter
def markup_unsafe(text):
- """Runs text through markdown allowing custom html
- """
+ """Runs text through markdown allowing custom html"""
return _markup(text, markdown_unsafe.convert)
markup_unsafe.is_safe = True
@register.filter
def userlink(user):
- """
- Display a username in HTML with a link to their profile
- """
+ """Display a username in HTML with a link to their profile"""
if not user or not user.id:
return ugettext('anonymous')
res = ugettext('<a title="View %(user)s\'s profile" class="user"'
@@ -184,19 +178,15 @@ def userlink(user):
@register.simple_tag
def translate_object(obj, lang):
- """
- If possible, replaces certain fields with translated text
- """
+ """If possible, replaces certain fields with translated text"""
if obj:
obj.translate(lang)
return ''
@register.simple_tag(takes_context=True)
def show_comments(context, user, comments):
- """
- I wrote this because template includes don't recurse properly
- """
+ """I wrote this because template includes don't recurse properly"""
res = []
depth = context.get('depth', -1) + 1
can_reply = depth + 1 < settings.OWS_MAX_COMMENT_DEPTH
Oops, something went wrong.

0 comments on commit 9939315

Please sign in to comment.