Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions cdeep/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Meta(object):


class UsersRoles(models.Model):
uid = models.ForeignKey(Users, db_column='uid')
rid = models.ForeignKey(Role, db_column='rid')
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
rid = models.ForeignKey(Role, db_column='rid', on_delete=models.PROTECT)

class Meta(object):
db_table = 'users_roles'
Expand Down Expand Up @@ -83,22 +83,22 @@ class Meta(object):

class TutorialCommonContents(models.Model):
id = models.IntegerField(primary_key=True)
tutorial_detail = models.ForeignKey(TutorialDetails)
tutorial_detail = models.ForeignKey(TutorialDetails, on_delete=models.PROTECT)
tutorial_slide = models.TextField()
tutorial_slide_uid = models.ForeignKey(Users, related_name='slides', db_column='tutorial_slide_uid')
tutorial_slide_uid = models.ForeignKey(Users, related_name='slides', db_column='tutorial_slide_uid', on_delete=models.PROTECT)
tutorial_slide_status = models.IntegerField()
tutorial_code = models.TextField()
tutorial_code_uid = models.ForeignKey(Users, related_name='codes', db_column='tutorial_code_uid')
tutorial_code_uid = models.ForeignKey(Users, related_name='codes', db_column='tutorial_code_uid', on_delete=models.PROTECT)
tutorial_code_status = models.IntegerField()
tutorial_assignment = models.TextField()
tutorial_assignment_uid = models.ForeignKey(Users, related_name='assignments', db_column='tutorial_assignment_uid')
tutorial_assignment_uid = models.ForeignKey(Users, related_name='assignments', db_column='tutorial_assignment_uid', on_delete=models.PROTECT)
tutorial_assignment_status = models.IntegerField()
tutorial_prerequisit = models.IntegerField()
tutorial_prerequisit_uid = models.ForeignKey(
Users, related_name='prerequisite', db_column='tutorial_prerequisit_uid')
Users, related_name='prerequisite', db_column='tutorial_prerequisit_uid', on_delete=models.PROTECT)
tutorial_prerequisit_status = models.IntegerField()
tutorial_keywords = models.TextField()
tutorial_keywords_uid = models.ForeignKey(Users, related_name='keywords', db_column='tutorial_keywords_uid')
tutorial_keywords_uid = models.ForeignKey(Users, related_name='keywords', db_column='tutorial_keywords_uid', on_delete=models.PROTECT)

class Meta(object):
db_table = 'tutorial_common_contents'
Expand All @@ -107,21 +107,21 @@ class Meta(object):

class TutorialResources(models.Model):
id = models.IntegerField(primary_key=True)
tutorial_detail = models.ForeignKey(TutorialDetails)
uid = models.ForeignKey(Users, db_column='uid')
tutorial_detail = models.ForeignKey(TutorialDetails, on_delete=models.PROTECT)
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
language = models.CharField(max_length=50)
upload_time = models.DateTimeField()
reviewer = models.CharField(max_length=400)
tutorial_content = models.ForeignKey(TutorialCommonContents)
tutorial_content = models.ForeignKey(TutorialCommonContents, on_delete=models.PROTECT)
tutorial_outline = models.TextField()
tutorial_outline_uid = models.ForeignKey(Users, related_name='outlines', db_column='tutorial_outline_uid')
tutorial_outline_uid = models.ForeignKey(Users, related_name='outlines', db_column='tutorial_outline_uid', on_delete=models.PROTECT)
tutorial_outline_status = models.IntegerField()
tutorial_script = models.TextField()
tutorial_script_uid = models.ForeignKey(Users, related_name='scripts', db_column='tutorial_script_uid')
tutorial_script_uid = models.ForeignKey(Users, related_name='scripts', db_column='tutorial_script_uid', on_delete=models.PROTECT)
tutorial_script_status = models.IntegerField()
tutorial_script_timed = models.TextField()
tutorial_video = models.TextField()
tutorial_video_uid = models.ForeignKey(Users, related_name='videos', db_column='tutorial_video_uid')
tutorial_video_uid = models.ForeignKey(Users, related_name='videos', db_column='tutorial_video_uid', on_delete=models.PROTECT)
tutorial_video_status = models.IntegerField()
tutorial_status = models.CharField(max_length=50)
cvideo_version = models.IntegerField()
Expand All @@ -135,8 +135,8 @@ class Meta(object):

class TutorialDomainReviewerRoles(models.Model):
id = models.IntegerField(primary_key=True)
uid = models.ForeignKey(Users, db_column='uid')
language = models.ForeignKey(TutorialLanguages)
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
language = models.ForeignKey(TutorialLanguages, on_delete=models.PROTECT)

class Meta(object):
db_table = 'tutorial_domain_reviewer_roles'
Expand All @@ -145,8 +145,8 @@ class Meta(object):

class TutorialQualityRoles(models.Model):
id = models.IntegerField(primary_key=True)
uid = models.ForeignKey(Users, db_column='uid')
language = models.ForeignKey(TutorialLanguages)
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
language = models.ForeignKey(TutorialLanguages, on_delete=models.PROTECT)

class Meta(object):
db_table = 'tutorial_quality_roles'
Expand All @@ -155,7 +155,7 @@ class Meta(object):

class TutorialUpdateLog(models.Model):
id = models.IntegerField(primary_key=True)
tutorial_resources = models.ForeignKey(TutorialResources)
tutorial_resources = models.ForeignKey(TutorialResources, on_delete=models.PROTECT)
update_time = models.DateTimeField()
updated_by = models.CharField(max_length=255)
updated_content = models.CharField(max_length=255)
Expand All @@ -167,8 +167,8 @@ class Meta(object):

class CTutorialMissingComponent(models.Model):
id = models.IntegerField(primary_key=True)
uid = models.ForeignKey(Users, db_column='uid')
trid = models.ForeignKey(TutorialResources, db_column='trid')
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
trid = models.ForeignKey(TutorialResources, db_column='trid', on_delete=models.PROTECT)
component = models.CharField(max_length=15)
type = models.IntegerField()
remarks = models.TextField()
Expand All @@ -186,7 +186,7 @@ class Meta(object):
class CTutorialMissingComponentReply(models.Model):
id = models.IntegerField(primary_key=True)
missing_component_id = models.IntegerField()
uid = models.ForeignKey(Users, db_column='uid')
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
reply_message = models.TextField()
created = models.DateTimeField()

Expand All @@ -197,8 +197,8 @@ class Meta(object):

class TutorialPublicReview(models.Model):
id = models.IntegerField(primary_key=True)
uid = models.ForeignKey(Users, db_column='uid')
trid = models.ForeignKey(TutorialResources, db_column='trid')
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
trid = models.ForeignKey(TutorialResources, db_column='trid', on_delete=models.PROTECT)
date_time = models.DateTimeField()
component = models.CharField(max_length=20)
comment = models.TextField()
Expand All @@ -210,7 +210,7 @@ class Meta(object):

class TutorialPublicReviewVideo(models.Model):
id = models.IntegerField(primary_key=True)
tutorial_public_review = models.ForeignKey(TutorialPublicReview)
tutorial_public_review = models.ForeignKey(TutorialPublicReview, on_delete=models.PROTECT)
item = models.IntegerField()
everywhere = models.IntegerField()
video_time = models.TimeField()
Expand All @@ -222,7 +222,7 @@ class Meta(object):

class UserRatings(models.Model):
id = models.IntegerField(primary_key=True)
uid = models.ForeignKey(Users, db_column='uid')
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
page_id = models.IntegerField()
rated_date = models.DateField()
rating = models.BigIntegerField()
Expand All @@ -234,8 +234,8 @@ class Meta(object):

class VideoComments(models.Model):
id = models.IntegerField(primary_key=True)
tutorial_resource = models.ForeignKey(TutorialResources)
uid = models.ForeignKey(Users, db_column='uid')
tutorial_resource = models.ForeignKey(TutorialResources, on_delete=models.PROTECT)
uid = models.ForeignKey(Users, db_column='uid', on_delete=models.PROTECT)
comments = models.TextField()
created_at = models.DateTimeField()

Expand Down
3 changes: 2 additions & 1 deletion certificate/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Third Party Stuff
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down Expand Up @@ -43,7 +44,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('uin', models.CharField(max_length=50)),
('attendance', models.NullBooleanField()),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
options={
},
Expand Down
3 changes: 2 additions & 1 deletion certificate/migrations/0003_auto_20160816_1148.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Third Party Stuff
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down Expand Up @@ -306,7 +307,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='answer',
name='question',
field=models.ForeignKey(to='certificate.Question'),
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='certificate.Question'),
preserve_default=True,
),
migrations.AddField(
Expand Down
25 changes: 13 additions & 12 deletions cms/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Third Party Stuff
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

# Spoken Tutorial Stuff
import cms.models
Expand Down Expand Up @@ -48,7 +49,7 @@ class Migration(migrations.Migration):
('source_link', models.URLField(max_length=255, null=True, blank=True)),
('event_date', models.DateTimeField()),
('created', models.DateTimeField(auto_now_add=True)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
Expand Down Expand Up @@ -76,7 +77,7 @@ class Migration(migrations.Migration):
('weight', models.PositiveIntegerField(default=3)),
('created', models.DateTimeField()),
('updated', models.DateTimeField()),
('created_by', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'New',
Expand All @@ -100,7 +101,7 @@ class Migration(migrations.Migration):
('expiry_date', models.DateField()),
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
Expand Down Expand Up @@ -132,11 +133,11 @@ class Migration(migrations.Migration):
('thumb', models.FileField(null=True, upload_to=cms.models.profile_picture_thumb, blank=True)),
('address', models.TextField(null=True)),
('created', models.DateTimeField(auto_now_add=True)),
('city', models.ForeignKey(to='events.City', null=True)),
('district', models.ForeignKey(to='events.District', null=True)),
('location', models.ForeignKey(to='events.Location', null=True)),
('state', models.ForeignKey(to='events.State', null=True)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('city', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='events.City', null=True)),
('district', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='events.District', null=True)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='events.Location', null=True)),
('state', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='events.State', null=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
Expand All @@ -159,22 +160,22 @@ class Migration(migrations.Migration):
('target_new', models.BooleanField()),
('visible', models.BooleanField()),
('created', models.DateTimeField(auto_now_add=True)),
('nav', models.ForeignKey(to='cms.Nav')),
('nav', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cms.Nav')),
],
),
migrations.AddField(
model_name='news',
name='news_type',
field=models.ForeignKey(to='cms.NewsType'),
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cms.NewsType'),
),
migrations.AddField(
model_name='news',
name='state',
field=models.ForeignKey(blank=True, to='events.State', null=True),
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, blank=True, to='events.State', null=True),
),
migrations.AddField(
model_name='block',
name='block_location',
field=models.ForeignKey(to='cms.Block_Location'),
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cms.Block_Location'),
),
]
3 changes: 0 additions & 3 deletions cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Third Party Stuff
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

# Spoken Tutorial Stuff
from events.models import City, District, Location, State
Expand Down Expand Up @@ -53,7 +52,6 @@ class Page(models.Model):
visible = models.BooleanField()
created = models.DateTimeField(auto_now_add=True)

@python_2_unicode_compatible
class Block_Location(models.Model):
name = models.CharField(max_length=255)
visible = models.BooleanField()
Expand Down Expand Up @@ -109,7 +107,6 @@ class Notification(models.Model):
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now = True)

@python_2_unicode_compatible
class NewsType(models.Model):
name = models.CharField(max_length = 50)
slug = models.CharField(max_length = 50)
Expand Down
2 changes: 1 addition & 1 deletion cms/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_user_email(email):
user = User.objects.filter(email__iexact=email)
if len(user) == 1:
return user[0]
return User.objects.get(email=email).first()
return User.objects.filter(email=email).first()
except ObjectDoesNotExist:
return None

Expand Down
2 changes: 1 addition & 1 deletion cms/templatetags/announcements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

register = template.Library()

@register.assignment_tag
@register.simple_tag
def get_notifications():
return Notification.objects.filter(Q(start_date__lte=dt.datetime.today()) & Q(
expiry_date__gte=dt.datetime.today())).order_by('expiry_date')
Expand Down
6 changes: 3 additions & 3 deletions cms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def confirm(request, confirmation_code, username):
def account_login(request):
user = request.user
error_msg = ''
if request.user.is_anonymous():
if not request.user.is_authenticated:
form = LoginForm()
context = {
'form' : form
Expand Down Expand Up @@ -386,7 +386,7 @@ def account_view_profile(request, username):
'profile' : profile,
'media_url' : settings.MEDIA_URL,
}
if request.user.is_authenticated():
if request.user.is_authenticated:
payee_list = Payee.objects.prefetch_related('cdfosslanguages_set__foss','cdfosslanguages_set__lang').filter(user=request.user)
context['payee_list'] = payee_list

Expand Down Expand Up @@ -506,7 +506,7 @@ def change_password(request):
user.backend = 'django.contrib.auth.backends.ModelBackend'
login(request, user)

if request.user.is_anonymous():
if not request.user.is_authenticated:
return HttpResponseRedirect('/accounts/login/?next=/accounts/change-password/')

if not profile:
Expand Down
Loading