Skip to content
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

No more magic snakecase #577

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 0 additions & 26 deletions django_facebook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,36 +366,12 @@ class FacebookCustomUser(AbstractUser, FacebookModel):
logger.info('Couldnt setup FacebookUser, got error %s', e)


class BaseModelMetaclass(ModelBase):

'''
Cleaning up the table naming conventions
'''

def __new__(cls, name, bases, attrs):
super_new = ModelBase.__new__(cls, name, bases, attrs)
module_name = camel_to_underscore(name)

app_label = super_new.__module__.split('.')[-2]
db_table = '%s_%s' % (app_label, module_name)

django_default = '%s_%s' % (app_label, name.lower())
if not getattr(super_new._meta, 'proxy', False):
db_table_is_default = django_default == super_new._meta.db_table
# Don't overwrite when people customize the db_table
if db_table_is_default:
super_new._meta.db_table = db_table

return super_new


@python_2_unicode_compatible
class BaseModel(models.Model):

'''
Stores the fields common to all incentive models
'''
__metaclass__ = BaseModelMetaclass

def __str__(self):
'''
Expand Down Expand Up @@ -527,8 +503,6 @@ class OpenGraphShare(BaseModel):
updated_at = models.DateTimeField(auto_now=True)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)

class Meta:
db_table = facebook_settings.FACEBOOK_OG_SHARE_DB_TABLE

def save(self, *args, **kwargs):
if self.user and not self.facebook_user_id:
Expand Down
2 changes: 1 addition & 1 deletion django_facebook/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
image_upload, name='facebook_image_upload'),
url(r'^canvas/$', canvas, name='facebook_canvas'),
url(r'^page_tab/$',
'page_tab', name=facebook_page_tab),
page_tab, name='facebook_page_tab'),
url(r'^open_graph_beta/$', open_graph_beta,
name='facebook_open_graph_beta'),
url(r'^remove_og_share/$', remove_og_share,
Expand Down