Switch to relative imports
The relative imports make it clearer what code is within the project and where it's coming from.
This commit is contained in:
parent
439f777bda
commit
b7e2ce2a4d
31 changed files with 131 additions and 84 deletions
|
@ -2,10 +2,6 @@ import hashlib
|
|||
|
||||
from django.conf import settings
|
||||
|
||||
# This is backwards compatibilty support for a custom function we wrote
|
||||
# ourselves that is no longer necessary in modern Django.
|
||||
from django.shortcuts import render as render_template_with_context
|
||||
|
||||
|
||||
class ParameterValidator:
|
||||
def __init__(self, given_hash_or_params, params_hash_key=None):
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# Generated by Django 1.11.29 on 2023-01-27 06:02
|
||||
|
||||
import conservancy.apps.assignment.models
|
||||
from django.db import migrations, models
|
||||
|
||||
from ..models import validate_mutiple_urls
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
@ -24,6 +23,6 @@ class Migration(migrations.Migration):
|
|||
migrations.AlterField(
|
||||
model_name='assignment',
|
||||
name='repositories',
|
||||
field=models.TextField(help_text='List of URLs, one per line', validators=[conservancy.apps.assignment.models.validate_mutiple_urls], verbose_name='Code repositories containing contributions of yours whose copyright you are assigning'),
|
||||
field=models.TextField(help_text='List of URLs, one per line', validators=[validate_mutiple_urls], verbose_name='Code repositories containing contributions of yours whose copyright you are assigning'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.blog.models import EntryTag, Entry
|
||||
|
||||
from .models import EntryTag, Entry
|
||||
|
||||
|
||||
class EntryTagAdmin(admin.ModelAdmin):
|
||||
prepopulated_fields = {'slug': ('label',)}
|
||||
|
||||
admin.site.register(EntryTag, EntryTagAdmin)
|
||||
|
||||
|
||||
class EntryAdmin(admin.ModelAdmin):
|
||||
list_display = ('pub_date', 'headline', 'author')
|
||||
list_filter = ['pub_date']
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from conservancy import bsoup
|
||||
from conservancy.apps.staff.models import Person
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from ... import bsoup
|
||||
from ..staff.models import Person
|
||||
|
||||
|
||||
class EntryTag(models.Model):
|
||||
"""Tagging for blog entries"""
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from django.conf.urls import url, include
|
||||
from conservancy.apps.blog.models import Entry, EntryTag # relative import
|
||||
from conservancy.apps.staff.models import Person
|
||||
from datetime import datetime
|
||||
from conservancy.apps.blog.views import last_name, BlogYearArchiveView, BlogMonthArchiveView, BlogDayArchiveView, BlogDateDetailView, custom_index, query
|
||||
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from .models import Entry, EntryTag
|
||||
from ..staff.models import Person
|
||||
from .views import last_name, BlogYearArchiveView, BlogMonthArchiveView, BlogDayArchiveView, BlogDateDetailView, custom_index, query
|
||||
|
||||
extra_context = {}
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
from conservancy.apps.blog.models import Entry, EntryTag # relative import
|
||||
# from django.views.generic.list_detail import object_list
|
||||
from datetime import datetime
|
||||
from functools import reduce
|
||||
|
||||
from django.views.generic import ListView
|
||||
from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from conservancy.apps.staff.models import Person
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from datetime import datetime
|
||||
from functools import reduce
|
||||
|
||||
from .models import Entry, EntryTag
|
||||
from ..staff.models import Person
|
||||
|
||||
|
||||
def OR_filter(field_name, objs):
|
||||
from django.db.models import Q
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.contacts.models import ContactEntry
|
||||
|
||||
from .models import ContactEntry
|
||||
|
||||
|
||||
class ContactEntryAdmin(admin.ModelAdmin):
|
||||
list_display = ('email', 'subscribe_conservancy')
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from django.shortcuts import render
|
||||
from django import forms
|
||||
from conservancy.apps.contacts.models import ContactEntry
|
||||
from django.forms import ModelForm
|
||||
|
||||
from .models import ContactEntry
|
||||
|
||||
|
||||
def subscribe(request):
|
||||
"""Mailing list subscription form
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.conf.urls import url, include
|
||||
from conservancy.apps.contractpatch import views as cpatch_views
|
||||
|
||||
from . import views as cpatch_views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'', cpatch_views.index),
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
from conservancy import render_template_with_context
|
||||
from conservancy.apps.blog.models import Entry as BlogEntry
|
||||
from datetime import datetime
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
from ..blog.models import Entry
|
||||
|
||||
|
||||
def index(request):
|
||||
filters = {
|
||||
'pub_date__lte': datetime.now(),
|
||||
'tags__slug': 'ContractPatch',
|
||||
}
|
||||
context = {
|
||||
'blog_entries': BlogEntry.objects.filter(**filters)[:3],
|
||||
'blog_entries': Entry.objects.filter(**filters)[:3],
|
||||
}
|
||||
return render_template_with_context(request, "contractpatch/index.html", context)
|
||||
return render(request, "contractpatch/index.html", context)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.events.models import EventTag, Event, EventMedia
|
||||
|
||||
from .models import EventTag, Event, EventMedia
|
||||
|
||||
admin.site.register(EventTag)
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from django.db import models
|
||||
from conservancy.apps.staff.models import Person
|
||||
from conservancy.apps.worldmap.models import EarthLocation
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.db import models
|
||||
|
||||
from ..staff.models import Person
|
||||
from ..worldmap.models import EarthLocation
|
||||
|
||||
|
||||
class EventTag(models.Model):
|
||||
"""Tagging for events
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.conf.urls import patterns, url, include
|
||||
from conservancy.apps.events.models import Event
|
||||
|
||||
from .models import Event
|
||||
|
||||
info_dict = {
|
||||
'queryset': Event.objects.all(),
|
||||
|
|
|
@ -3,9 +3,9 @@ from django.shortcuts import render
|
|||
from django.http import Http404, HttpResponse
|
||||
from django.template import loader
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from conservancy.apps.events.models import Event
|
||||
# for debugging...
|
||||
from django.http import HttpResponse
|
||||
|
||||
from .models import Event
|
||||
|
||||
|
||||
def event_detail(request, year, slug, queryset, **kwargs):
|
||||
"""This view shows event detail.
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.fundgoal import models as fundgoal_models
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
class FundraisingGoalAdmin(admin.ModelAdmin):
|
||||
list_display = ('fundraiser_code_name', 'fundraiser_goal_amount')
|
||||
|
||||
|
||||
class GoalProviderAdmin(admin.ModelAdmin):
|
||||
fields = [
|
||||
'fundraising_goal',
|
||||
'provider_name',
|
||||
]
|
||||
|
||||
admin.site.register(fundgoal_models.FundraisingGoal, FundraisingGoalAdmin)
|
||||
admin.site.register(fundgoal_models.GoalProvider, GoalProviderAdmin)
|
||||
admin.site.register(models.FundraisingGoal, FundraisingGoalAdmin)
|
||||
admin.site.register(models.GoalProvider, GoalProviderAdmin)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from conservancy.apps.fundgoal.models import FundraisingGoal
|
||||
from django.http import JsonResponse
|
||||
|
||||
from .models import FundraisingGoal
|
||||
|
||||
|
||||
def view(request):
|
||||
"""JSON version of request
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.news.models import PressRelease, ExternalArticleTag, ExternalArticle
|
||||
|
||||
from .models import PressRelease, ExternalArticleTag, ExternalArticle
|
||||
|
||||
|
||||
class PressReleaseAdmin(admin.ModelAdmin):
|
||||
list_display = ("headline", "pub_date")
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from conservancy import bsoup
|
||||
from conservancy.apps.staff.models import Person
|
||||
from conservancy.apps.events.models import Event
|
||||
from django.contrib.sites.models import Site
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from ... import bsoup
|
||||
from ..staff.models import Person
|
||||
from ..events.models import Event
|
||||
|
||||
|
||||
class PressRelease(models.Model, bsoup.SoupModelMixin):
|
||||
"""News release model"""
|
||||
|
|
|
@ -19,8 +19,9 @@
|
|||
|
||||
from django.conf.urls import url, include
|
||||
from django.conf import settings
|
||||
from conservancy.apps.news.models import PressRelease, ExternalArticle
|
||||
from conservancy.apps.news.views import NewsYearArchiveView, NewsMonthArchiveView, NewsDayArchiveView, NewsDateDetailView, listing
|
||||
|
||||
from .models import PressRelease, ExternalArticle
|
||||
from .views import NewsYearArchiveView, NewsMonthArchiveView, NewsDayArchiveView, NewsDateDetailView, listing
|
||||
|
||||
info_dict = {
|
||||
'queryset': PressRelease.objects.all().filter(sites__id__exact=settings.SITE_ID),
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
# from django.views.generic.list_detail import object_list
|
||||
from datetime import datetime
|
||||
|
||||
from django.views.generic import ListView
|
||||
from django.shortcuts import render
|
||||
from django.views.generic.dates import YearArchiveView, MonthArchiveView, DayArchiveView, DateDetailView
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from conservancy.apps.news.models import ExternalArticle
|
||||
from conservancy.apps.news.models import PressRelease
|
||||
from conservancy.apps.events.models import Event
|
||||
from datetime import datetime
|
||||
# for debugging...
|
||||
from django.http import HttpResponse
|
||||
|
||||
from .models import ExternalArticle
|
||||
from .models import PressRelease
|
||||
from ..events.models import Event
|
||||
|
||||
|
||||
class NewsListView(ListView):
|
||||
extra_context = {}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.staff.models import Person
|
||||
|
||||
from .models import Person
|
||||
|
||||
|
||||
class PersonAdmin(admin.ModelAdmin):
|
||||
list_display = ("username", "formal_name", "casual_name",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.summit_registration.models import SummitRegistration
|
||||
|
||||
from .models import SummitRegistration
|
||||
|
||||
|
||||
class SummitRegistrationAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'email', 'affiliation', 'cle_credit')
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from django.conf.urls import url
|
||||
from django.views.generic import TemplateView
|
||||
from conservancy.apps.supporter import views as supp_views
|
||||
from conservancy.static import views as static_views
|
||||
|
||||
from . import views as supp_views
|
||||
from ...static import views as static_views
|
||||
|
||||
INDEX_VIEW = supp_views.index
|
||||
urlpatterns = [
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
import conservancy
|
||||
|
||||
|
||||
def index(request):
|
||||
with conservancy.ParameterValidator(request.GET, 'upgrade_id') as validator:
|
||||
try:
|
||||
|
@ -13,4 +16,4 @@ def index(request):
|
|||
'partial_amount': partial_amount,
|
||||
'minimum_amount': 120 - partial_amount,
|
||||
}
|
||||
return conservancy.render_template_with_context(request, "supporter/index.html", context)
|
||||
return render(request, "supporter/index.html", context)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.supporters.models import Supporter
|
||||
|
||||
from .models import Supporter
|
||||
|
||||
|
||||
class SupporterAdmin(admin.ModelAdmin):
|
||||
list_display = ('display_name', 'display_until_date')
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from conservancy.apps.worldmap.models import EarthLocation
|
||||
|
||||
from .models import EarthLocation
|
||||
|
||||
|
||||
class EarthLocationAdmin(admin.ModelAdmin):
|
||||
list_display = ("label", "html_map_link")
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
from django.contrib.syndication.views import Feed
|
||||
from django.utils.feedgenerator import Rss201rev2Feed
|
||||
from conservancy.apps.news.models import PressRelease
|
||||
from conservancy.apps.blog.models import Entry as BlogEntry
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from datetime import datetime
|
||||
|
||||
from functools import reduce
|
||||
import itertools
|
||||
import operator
|
||||
from functools import reduce
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.syndication.views import Feed
|
||||
from django.shortcuts import render
|
||||
from django.utils.feedgenerator import Rss201rev2Feed
|
||||
|
||||
from .apps.blog.models import Entry as BlogEntry
|
||||
from .apps.news.models import PressRelease
|
||||
|
||||
|
||||
class ConservancyFeedBase(Feed):
|
||||
def copyright_holder(self): return "Software Freedom Conservancy"
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
from conservancy import render_template_with_context
|
||||
from conservancy.apps.supporters.models import Supporter as Supporter
|
||||
from conservancy.apps.news.models import PressRelease
|
||||
from conservancy.apps.blog.models import Entry as BlogEntry
|
||||
from datetime import datetime
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
from .apps.blog.models import Entry
|
||||
from .apps.news.models import PressRelease
|
||||
from .apps.supporters.models import Supporter
|
||||
|
||||
|
||||
def view(request):
|
||||
"""Conservancy front page view
|
||||
|
||||
Performs all object queries necessary to render the front page.
|
||||
"""
|
||||
|
||||
now = datetime.now()
|
||||
context = {
|
||||
'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5],
|
||||
'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(),
|
||||
'blog': BlogEntry.objects.all().filter(pub_date__lte=now)[:5],
|
||||
'blog': Entry.objects.all().filter(pub_date__lte=now)[:5],
|
||||
}
|
||||
return render_template_with_context(request, "frontpage.html", context)
|
||||
return render(request, "frontpage.html", context)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime as DateTime
|
||||
|
||||
import conservancy.settings
|
||||
from conservancy.apps.fundgoal.models import FundraisingGoal as FundraisingGoal
|
||||
from . import settings
|
||||
from .apps.fundgoal.models import FundraisingGoal
|
||||
|
||||
SITE_FUNDGOAL = 'cy2022-end-year-match'
|
||||
|
||||
|
@ -18,8 +18,8 @@ def sitefundraiser(request):
|
|||
'sitefundgoal': fundgoal_lookup(SITE_FUNDGOAL),
|
||||
}
|
||||
|
||||
if conservancy.settings.FORCE_CANONICAL_HOSTNAME:
|
||||
_HOST_URL_VAR = {'host_url': 'https://' + conservancy.settings.FORCE_CANONICAL_HOSTNAME}
|
||||
if settings.FORCE_CANONICAL_HOSTNAME:
|
||||
_HOST_URL_VAR = {'host_url': 'https://' + settings.FORCE_CANONICAL_HOSTNAME}
|
||||
def host_url(request):
|
||||
return _HOST_URL_VAR
|
||||
else:
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
from django.shortcuts import render
|
||||
from conservancy.apps.supporters.models import Supporter as Supporter
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
from .apps.supporters.models import Supporter
|
||||
|
||||
|
||||
def view(request):
|
||||
"""Conservancy Sponsors Page view
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
|
||||
from conservancy import feeds, frontpage, sponsors
|
||||
import conservancy.apps.fundgoal.views as fundgoal_views
|
||||
import conservancy.static.views as static_views
|
||||
from . import feeds, frontpage, sponsors
|
||||
from .apps.fundgoal import views as fundgoal_views
|
||||
from .static import views as static_views
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
|
|
Loading…
Reference in a new issue