Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved things around and added FKs

  • Loading branch information...
commit 075b995c441d54b046fe04386ff68ef3add91b12 1 parent f774f54
@shabda shabda authored
Showing with 81 additions and 66 deletions.
  1. +0 −1  wp/admin.py
  2. +81 −65 wp/models.py
View
1  wp/admin.py
@@ -17,4 +17,3 @@
admin.site.register(Option)
admin.site.register(YarppKeywordCache)
admin.site.register(YarppRelatedCache)
-
View
146 wp/models.py
@@ -1,42 +1,29 @@
from django.db import models
-class Comment(models.Model):
- comment_id = models.IntegerField(primary_key=True, db_column='comment_ID') # Field name made lowercase.
- comment_post_id = models.IntegerField(db_column='comment_post_ID') # Field name made lowercase.
- comment_author = models.TextField()
- comment_author_email = models.CharField(max_length=300)
- comment_author_url = models.CharField(max_length=600)
- comment_author_ip = models.CharField(max_length=300, db_column='comment_author_IP') # Field name made lowercase.
- comment_date = models.DateTimeField()
- comment_date_gmt = models.DateTimeField()
- comment_content = models.TextField()
- comment_karma = models.IntegerField()
- comment_approved = models.CharField(max_length=60)
- comment_agent = models.CharField(max_length=765)
- comment_type = models.CharField(max_length=60)
- comment_parent = models.IntegerField()
- user_id = models.IntegerField()
- class Meta:
- verbose_name = "Comment"
- verbose_name_plural = "Comments"
- db_table = u'wp_comments'
-
- def __unicode__(self):
- return self.comment_content[:50]
-
-class CommentMeta(models.Model):
- meta_id = models.IntegerField(primary_key=True)
- #comment = models.ForeignKey(Comment)
- comment_id = models.IntegerField()
- meta_key = models.CharField(max_length=765, blank=True)
- meta_value = models.TextField(blank=True)
+
+class WpUser(models.Model):
+ """This has been given a wp prefix, as contrib.user is so commonly
+ imported name, and we do not wnat to namespace this everywhere."""
+
+ id = models.IntegerField(primary_key=True, db_column='ID') # Field name made lowercase.
+ user_login = models.CharField(max_length=180)
+ user_pass = models.CharField(max_length=192)
+ user_nicename = models.CharField(max_length=150)
+ user_email = models.CharField(max_length=300)
+ user_url = models.CharField(max_length=300)
+ user_registered = models.DateTimeField()
+ user_activation_key = models.CharField(max_length=180)
+ user_status = models.IntegerField()
+ display_name = models.CharField(max_length=750)
class Meta:
- verbose_name = "Comment Meta"
- verbose_name_plural = "Comments Meta"
- db_table = u'wp_commentmeta'
+ verbose_name = "User"
+ verbose_name_plural = "Users"
+ db_table = u'wp_users'
def __unicode__(self):
- return self.meta_key
+ return self.user_nicename
+
+
class Link(models.Model):
link_id = models.IntegerField(primary_key=True)
@@ -47,7 +34,7 @@ class Link(models.Model):
link_category = models.IntegerField()
link_description = models.CharField(max_length=765)
link_visible = models.CharField(max_length=60)
- link_owner = models.IntegerField()
+ link_owner = models.ForeignKey(WpUser, db_column = "link_owner")
link_rating = models.IntegerField()
link_updated = models.DateTimeField()
link_rel = models.CharField(max_length=765)
@@ -78,8 +65,11 @@ def __unicode__(self):
class Post(models.Model):
id = models.IntegerField(db_column='ID', primary_key = True) # Field name made lowercase.
+ guid = models.CharField(max_length=765)
+
post_author = models.ForeignKey("wp.WpUser", db_column = "post_author")
post_parent = models.ForeignKey("self", db_column="post_parent")
+
post_date = models.DateTimeField()
post_date_gmt = models.DateTimeField()
post_content = models.TextField()
@@ -87,21 +77,24 @@ class Post(models.Model):
post_category = models.IntegerField()
post_excerpt = models.TextField()
post_status = models.CharField(max_length=60)
- comment_status = models.CharField(max_length=60)
- ping_status = models.CharField(max_length=60)
- post_password = models.CharField(max_length=60)
post_name = models.CharField(max_length=600)
- to_ping = models.TextField()
- pinged = models.TextField()
+ post_password = models.CharField(max_length=60)
post_modified = models.DateTimeField()
post_modified_gmt = models.DateTimeField()
post_content_filtered = models.TextField()
- guid = models.CharField(max_length=765)
- menu_order = models.IntegerField()
post_type = models.CharField(max_length=60)
post_mime_type = models.CharField(max_length=300)
+
+ comment_status = models.CharField(max_length=60)
comment_count = models.IntegerField()
+ ping_status = models.CharField(max_length=60)
+ to_ping = models.TextField()
+ pinged = models.TextField()
+
+ menu_order = models.IntegerField()
+
+
class Meta:
verbose_name = "Post"
verbose_name_plural = "Posts"
@@ -113,8 +106,10 @@ def __unicode__(self):
class PostMeta(models.Model):
meta_id = models.IntegerField(primary_key=True)
post = models.ForeignKey(Post)
+
meta_key = models.CharField(max_length=765, blank=True)
meta_value = models.TextField(blank=True)
+
class Meta:
verbose_name = "Post Meta"
verbose_name_plural = "Posts Meta"
@@ -122,12 +117,55 @@ class Meta:
def __unicode__(self):
return self.post.post_title or str(self.post.id)
+
+
+class Comment(models.Model):
+ comment_id = models.IntegerField(primary_key=True, db_column='comment_ID') # Field name made lowercase.
+ comment_post_id = models.ForeignKey(Post, db_column='comment_post_ID') # Field name made lowercase.
+ comment_author = models.TextField()
+ comment_author_email = models.CharField(max_length=300)
+ comment_author_url = models.CharField(max_length=600)
+ comment_author_ip = models.CharField(max_length=300, db_column='comment_author_IP') # Field name made lowercase.
+ comment_date = models.DateTimeField()
+ comment_date_gmt = models.DateTimeField()
+ comment_content = models.TextField()
+ comment_karma = models.IntegerField()
+ comment_approved = models.CharField(max_length=60)
+ comment_agent = models.CharField(max_length=765)
+ comment_type = models.CharField(max_length=60)
+ comment_parent = models.IntegerField()
+
+ user_id = models.IntegerField()#We can not make this a FK as for WP sets the integer field to 0, in case of non registered users
+
+ class Meta:
+ verbose_name = "Comment"
+ verbose_name_plural = "Comments"
+ db_table = u'wp_comments'
+
+ def __unicode__(self):
+ return self.comment_content[:50]
+
+class CommentMeta(models.Model):
+ meta_id = models.IntegerField(primary_key=True)
+ #comment = models.ForeignKey(Comment)
+ comment_id = models.IntegerField()
+ meta_key = models.CharField(max_length=765, blank=True)
+ meta_value = models.TextField(blank=True)
+ class Meta:
+ verbose_name = "Comment Meta"
+ verbose_name_plural = "Comments Meta"
+ db_table = u'wp_commentmeta'
+
+ def __unicode__(self):
+ return self.meta_key
+
class Term(models.Model):
term_id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=600)
slug = models.CharField(unique=True, max_length=255)
term_group = models.IntegerField()
+
class Meta:
verbose_name = "Term"
verbose_name_plural = "Terms"
@@ -163,33 +201,11 @@ class Meta:
db_table = u'wp_term_relationships'
-class WpUser(models.Model):
- """This has been given a wp prefix, as contrib.user is so commonly
- imported name, and we do not wnat to namespace this everywhere."""
-
- id = models.IntegerField(primary_key=True, db_column='ID') # Field name made lowercase.
- user_login = models.CharField(max_length=180)
- user_pass = models.CharField(max_length=192)
- user_nicename = models.CharField(max_length=150)
- user_email = models.CharField(max_length=300)
- user_url = models.CharField(max_length=300)
- user_registered = models.DateTimeField()
- user_activation_key = models.CharField(max_length=180)
- user_status = models.IntegerField()
- display_name = models.CharField(max_length=750)
- class Meta:
- verbose_name = "User"
- verbose_name_plural = "Users"
- db_table = u'wp_users'
-
- def __unicode__(self):
- return self.user_nicename
-
-
class UserMeta(models.Model):
umeta_id = models.IntegerField(primary_key=True)
user = models.ForeignKey(WpUser)
+
meta_key = models.CharField(max_length=765, blank=True)
meta_value = models.TextField(blank=True)
class Meta:
Please sign in to comment.
Something went wrong with that request. Please try again.