Skip to content

Commit

Permalink
Upgrade Junction to Python 3.10 & Django 3.2 along with Social Login …
Browse files Browse the repository at this point in the history
…Fix (#744)

* Upgrade Python Version to 3.10 and Django Version 3.2

* Fix Github and Google Login/Signup

* new package added to the requirements file

* using f-strings

Co-authored-by: @rohitchopra-epam
  • Loading branch information
Bhandari423 committed Jan 10, 2023
1 parent 69afa7a commit 01b8332
Show file tree
Hide file tree
Showing 53 changed files with 337 additions and 182 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ qr_files/
#VSCode
.vscode/

tmp/
tmp/
13 changes: 7 additions & 6 deletions junction/base/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ def new_render(cls, context):


def patch_urlresolvers():
from django.core import urlresolvers # noqa
from django.urls import get_urlconf, get_resolver # noqa
from django.conf import settings # noqa

if hasattr(urlresolvers, "_patched"):
urlconf = get_urlconf()
resolver = get_resolver(urlconf)
if hasattr(resolver, "_patched"):
return

old_reverse = urlresolvers.reverse
old_reverse = resolver.reverse

def new_reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
path = old_reverse(
Expand All @@ -45,5 +46,5 @@ def new_reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None

return settings.SITE_URL + path

urlresolvers._patched = True
urlresolvers.reverse = new_reverse
resolver._patched = True
resolver.reverse = new_reverse
29 changes: 6 additions & 23 deletions junction/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,22 @@

def get_date_diff_display(start, end):
if end.year != start.year:
return "%s - %s" % (start.strftime("%-d %b %Y"), end.strftime("%-d %b %Y"))
return f"{start.strftime('%d %b %Y')} - {end.strftime('%d %b %Y')}"

# year are same now
if end.month != start.month:
return "%s - %s, %s" % (
start.strftime("%-d %b"),
end.strftime("%-d %b"),
start.year,
)
return f"{start.strftime('%d %b')} - {end.strftime('%d %b')}, {start.year}"

# month and year are same now
if end.day != start.day:
return "%s-%s %s, %s" % (
start.strftime("%d"),
end.strftime("%d"),
start.strftime("%b"),
start.year,
)
return f"{start.strftime('%d')} - {end.strftime('%d')} {start.strftime('%b')}, {start.year}"

# day, month and year are same now
if isinstance(start, dt.date):
return "%s" % (start.strftime("%-d %b %Y"))
return f"{start.strftime('%d %b %Y')}"

# am/pm, day, month and year are same now
if end.strftime("%p") != start.strftime("%p"):
return "%s - %s, %s" % (
start.strftime("%-I:%M%p"),
end.strftime("%-I:%M%p"),
start.strftime("%-d %b %Y"),
)
return f"{start.strftime('%I:%M%p')} - {end.strftime('%I:%M%p')}, {start.strftime('%d %b %Y')}"

return "%s - %s%s" % (
start.strftime("%-I:%M"),
end.strftime("%-I:%M"),
start.strftime("%p, %-d %b %Y"),
)
return f"{start.strftime('%I:%M')} - {end.strftime('%I:%M')}{start.strftime('%p, %d %b %Y')}"
40 changes: 40 additions & 0 deletions junction/conferences/migrations/0016_auto_20230110_1818.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.2 on 2023-01-10 12:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('conferences', '0015_auto_20200322_1904'),
]

operations = [
migrations.AlterModelOptions(
name='historicalconferenceproposalreviewer',
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical proposals reviewer', 'verbose_name_plural': 'historical proposals reviewers'},
),
migrations.AddField(
model_name='historicalconferenceproposalreviewer',
name='history_change_reason',
field=models.CharField(max_length=100, null=True),
),
migrations.AlterField(
model_name='historicalconferenceproposalreviewer',
name='created_by',
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Created By'),
),
migrations.AlterField(
model_name='historicalconferenceproposalreviewer',
name='history_date',
field=models.DateTimeField(db_index=True),
),
migrations.AlterField(
model_name='historicalconferenceproposalreviewer',
name='modified_by',
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Modified By'),
),
]
4 changes: 2 additions & 2 deletions junction/conferences/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from six import python_2_unicode_compatible
from django.utils.timezone import now
from django.utils.translation import ugettext as _
from django_extensions.db.fields import AutoSlugField
Expand Down
2 changes: 1 addition & 1 deletion junction/conferences/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def is_reviewer(user, conference):
"""Returns a boolean indicating if a given user is a conference reviewer.
"""
if not user.is_authenticated():
if not user.is_authenticated:
return False

qs = ConferenceProposalReviewer.objects.filter(
Expand Down
7 changes: 4 additions & 3 deletions junction/conferences/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http.response import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views.decorators.http import require_http_methods
from rest_framework import filters, viewsets
from rest_framework import viewsets
from django_filters import rest_framework as filters

from .models import Conference, ConferenceVenue, Room
from .serializers import ConferenceSerializer, RoomSerializer, VenueSerializer
Expand All @@ -24,7 +25,7 @@ class VenueView(viewsets.ReadOnlyModelViewSet):
class RoomView(viewsets.ReadOnlyModelViewSet):
queryset = Room.objects.all()
serializer_class = RoomSerializer
filter_backend = (filters.DjangoFilterBackend,)
filter_backends = [filters.DjangoFilterBackend,]
filter_fields = ("venue",)


Expand Down
3 changes: 1 addition & 2 deletions junction/devices/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import uuidfield.fields
from django.db import migrations, models

import junction.devices.models
Expand Down Expand Up @@ -36,7 +35,7 @@ class Migration(migrations.Migration):
),
(
"uuid",
uuidfield.fields.UUIDField(
models.UUIDField(
unique=True, max_length=32, db_index=True
),
),
Expand Down
4 changes: 1 addition & 3 deletions junction/devices/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from django.db import models
from django.utils.timezone import now
from uuidfield import UUIDField

from junction.base.models import TimeAuditModel

Expand All @@ -14,8 +13,7 @@ def expiry_time(expiry_mins=60):


class Device(TimeAuditModel):
uuid = UUIDField(version=1, hyphenate=True, unique=True, db_index=True)

uuid = models.UUIDField(unique=True, db_index=True)
# Verification
is_verified = models.BooleanField(default=False)
verification_code = models.IntegerField()
Expand Down
2 changes: 1 addition & 1 deletion junction/feedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import absolute_import, unicode_literals

from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from six import python_2_unicode_compatible

from junction.base.models import TimeAuditModel
from junction.conferences.models import Conference
Expand Down
2 changes: 1 addition & 1 deletion junction/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.views.decorators.http import require_http_methods
Expand Down
2 changes: 1 addition & 1 deletion junction/proposals/comments_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http.response import (
HttpResponse,
HttpResponseForbidden,
Expand Down
14 changes: 7 additions & 7 deletions junction/proposals/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _get_proposal_section_reviewer_vote_choices(conference):
return values


class HorizRadioRenderer(forms.RadioSelect.renderer):
class HorizRadioRenderer(forms.RadioSelect):

"""
This overrides widget method to put radio buttons horizontally instead of vertically.
Expand All @@ -89,7 +89,7 @@ class ProposalForm(forms.Form):
widget=forms.TextInput(attrs={"class": "charfield"}),
)
description = forms.CharField(
widget=PagedownWidget(show_preview=True), help_text=("Describe your Proposal")
widget=PagedownWidget(attrs={"show_preview":True}), help_text=("Describe your Proposal")
)
target_audience = forms.ChoiceField(
label="Target Audience",
Expand All @@ -114,7 +114,7 @@ class ProposalForm(forms.Form):
# Additional Content
prerequisites = forms.CharField(
label="Pre-requisites",
widget=PagedownWidget(show_preview=True),
widget=PagedownWidget(attrs={"show_preview":True}),
required=False,
help_text="What should the participants know before attending your session?",
)
Expand All @@ -126,7 +126,7 @@ class ProposalForm(forms.Form):
)
content_urls = forms.CharField(
label="Content URLs",
widget=PagedownWidget(show_preview=True),
widget=PagedownWidget(attrs={"show_preview":True}),
required=False,
help_text="Links to your session like GitHub repo, Blog, Slideshare etc ...",
)
Expand All @@ -137,7 +137,7 @@ class ProposalForm(forms.Form):
)
speaker_info = forms.CharField(
label="Speaker Information",
widget=PagedownWidget(show_preview=True),
widget=PagedownWidget(attrs={"show_preview":True}),
required=False,
help_text="Say something about yourself, work etc...",
)
Expand All @@ -149,7 +149,7 @@ class ProposalForm(forms.Form):
)
speaker_links = forms.CharField(
label="Speaker Links",
widget=PagedownWidget(show_preview=True),
widget=PagedownWidget(attrs={"show_preview":True}),
required=False,
help_text="Links to your previous work like Blog, Open Source Contributions etc ...",
)
Expand Down Expand Up @@ -192,7 +192,7 @@ class ProposalCommentForm(forms.Form):
Used to add comments
"""

comment = forms.CharField(widget=PagedownWidget(show_preview=True))
comment = forms.CharField(widget=PagedownWidget(attrs={"show_preview":True}))
private = forms.BooleanField(required=False, widget=forms.HiddenInput())
reviewer = forms.BooleanField(required=False, widget=forms.HiddenInput())

Expand Down
74 changes: 74 additions & 0 deletions junction/proposals/migrations/0031_auto_20230110_1818.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Generated by Django 3.2 on 2023-01-10 12:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('proposals', '0030_auto_20200805_2137'),
]

operations = [
migrations.AlterModelOptions(
name='historicalproposal',
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical proposal', 'verbose_name_plural': 'historical proposals'},
),
migrations.AlterModelOptions(
name='historicalproposalsectionreviewervote',
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical ProposalSectionReviewerVote', 'verbose_name_plural': 'historical ProposalSectionReviewerVotes'},
),
migrations.AddField(
model_name='historicalproposal',
name='history_change_reason',
field=models.CharField(max_length=100, null=True),
),
migrations.AddField(
model_name='historicalproposalsectionreviewervote',
name='history_change_reason',
field=models.CharField(max_length=100, null=True),
),
migrations.AlterField(
model_name='historicalproposal',
name='author',
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Primary Speaker'),
),
migrations.AlterField(
model_name='historicalproposal',
name='history_date',
field=models.DateTimeField(db_index=True),
),
migrations.AlterField(
model_name='historicalproposal',
name='is_first_time_speaker',
field=models.BooleanField(blank=True, default=False),
),
migrations.AlterField(
model_name='historicalproposal',
name='proposal_section',
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='proposals.proposalsection', verbose_name='Proposal Section'),
),
migrations.AlterField(
model_name='historicalproposal',
name='proposal_type',
field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='proposals.proposaltype', verbose_name='Proposal Type'),
),
migrations.AlterField(
model_name='historicalproposalsectionreviewervote',
name='history_date',
field=models.DateTimeField(db_index=True),
),
migrations.AlterField(
model_name='proposal',
name='is_first_time_speaker',
field=models.BooleanField(blank=True, default=False),
),
migrations.AlterField(
model_name='proposalcomment',
name='is_spam',
field=models.BooleanField(blank=True, default=False),
),
]
4 changes: 2 additions & 2 deletions junction/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from datetime import datetime

from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db import models
from django.template.defaultfilters import slugify
from django.utils.encoding import python_2_unicode_compatible
from six import python_2_unicode_compatible
from django_extensions.db.fields import AutoSlugField
from hashids import Hashids
from rest_framework.reverse import reverse as rf_reverse
Expand Down
Loading

0 comments on commit 01b8332

Please sign in to comment.