Skip to content

Commit

Permalink
Tweak templates between dart_data and this repo, and fix test failure
Browse files Browse the repository at this point in the history
related to automatic forwarding
  • Loading branch information
rschwiebert committed Mar 5, 2023
1 parent c4f2768 commit c083679
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 22 deletions.
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ six = "1.11.0"
sqlparse = "0.3.0"
sympy = "1.9"
whitenoise = "5.0.1"
dart-data = {git = "https://github.com/rschwiebert/dart_data.git", branch="master"}
dart-data = {git = "https://github.com/rschwiebert/dart_data.git", rev="b1e69d0413a9e807d5441defece070bb97499fc1"}
psycopg2 = "2.9.3"
django-heroku = "0.3.1"

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
asgiref==3.5.1 ; python_version >= "3.10" and python_version < "4.0"
boto3==1.24.0 ; python_version >= "3.10" and python_version < "4.0"
botocore==1.27.96 ; python_version >= "3.10" and python_version < "4.0"
dart-data @ git+https://github.com/rschwiebert/dart_data.git@master ; python_version >= "3.10" and python_version < "4.0"
dart-data @ git+https://github.com/rschwiebert/dart_data.git@b1e69d0413a9e807d5441defece070bb97499fc1 ; python_version >= "3.10" and python_version < "4.0"
dj-database-url==0.5.0 ; python_version >= "3.10" and python_version < "4.0"
django-heroku==0.3.1 ; python_version >= "3.10" and python_version < "4.0"
django-mathfilters==0.4.0 ; python_version >= "3.10" and python_version < "4.0"
Expand Down
76 changes: 76 additions & 0 deletions ringapp/templates/ringapp/contribute.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{% extends 'base.html' %}

{% block title %}Contribute{% endblock %}

{% block content %}
{% if messages %}

<ul class="messages">
{% for message in messages %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
{{ message }}
</div>
{% endfor %}
</ul>
{% endif %}

<div class="container">
<div class="row">
<div class="col-md-6 content">
<h1>How to contribute</h1>
<p>You will either need to register here on this site, or else have a GitHub account.</p>

<p>For bug reports, feature requests, or problems with <b>the website itself</b>, use the
<a href="https://github.com/rschwiebert/RingApp/issues">RingApp GitHub issue tracker</a>.</p>
<p>For suggestions or corrections to <b>the database content</b>, use the
<a href="https://github.com/rschwiebert/dart_data/issues">dart_data GitHub issue tracker</a>.</p>
<p>If you are knowledgable enough and would like to formulate your own pull request with changes,
<a href="https://gist.github.com/MarcDiethelm/7303312">here is a brief guide for how to do
that for a GitHub project.</a></p>
<p>If you don't want to use GitHub, you can always use the form below to make any suggestion.</p>

<h2>Make a quick suggestion</h2>

{% if user.is_authenticated %}
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit suggestion"/>
</form>
{% else %}
<p>(When you <a href="{% url 'auth_login' %}?next=/contribute/">log in</a> the submission form appears
here.)
</p>
{% endif %}

</div>
<div class="col-md-6 content">
<h2>Need inspiration?</h2>

<p><a href="{% url 'inspiration' %}">Here is a list outlining several gaps
that remain to be filled.</a></p>
<h2>Relevant open questions</h2>
{% include 'dart_data/unknown_list.html' %}

<h2>Tips</h2>
<p>To help maintain the quality of content and integrity of the database, please keep these points in
mind:</p>
<ul>
<li> We might not accept every suggestion.</li>
<li> Did you check the database to see if your ring example or property is already there? (Accidents
will
happen and we can deal with it, but it's best to avoid that altogether.)
</li>
<li> It is really important to have good citations! (Incorrect proofs and claims exist,
unfortunately.)
</li>
<li> Multiple high-quality citations are helpful. (Readers will have more places to look.)</li>
</ul>
</div>

</div>
<div class="row">
{% include 'dart_data/contribution_list.html' %}
</div>
{% endblock %}
23 changes: 23 additions & 0 deletions ringapp/templates/ringapp/contributors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends 'base.html' %}

{% block title %}Contributors{% endblock %}

{% block content %}
{% if messages %}

<ul class="messages">
{% for message in messages %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
{{ message }}
</div>
{% endfor %}
</ul>
{% endif %}

<div class="container">
{% include 'dart_data/contribution_list.html' %}
</div>

{% endblock %}
16 changes: 16 additions & 0 deletions ringapp/templates/ringapp/no_expanded_details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'base.html' %}

{% block title %}Oops!{% endblock %}

{% block content %}

<div class="container">
<div class="col-md-12 content">
<h2>No expanded details for this ring available.</h2>
<p>You can request the creation of a page for this ring using the
<a href="{% url 'contribute' %}">suggestion form</a>.</p>
<p><a href="{% url 'ring-detail' ring.id %}">Back to the ring property page.</a></p>
</div>
</div>

{% endblock %}
4 changes: 2 additions & 2 deletions ringapp/tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_gets(self):
'search', 'results', 'theorem-list', 'inspiration']

for item in two_hundreds:
resp = self.client.get(reverse(item))
resp = self.client.get(reverse(item), follow=True)
self.assertEqual(resp.status_code, 200, item)

three_hundreds = ['auth_password_change', 'commproperty-list', 'cresults', 'profile', 'newsfeed']
Expand All @@ -47,7 +47,7 @@ def test_gets(self):
details = ['property-detail', 'theorem-detail',
'keyword-detail', 'ring-detail', 'expanded-detail', ]
for item in details:
resp = self.client.get(reverse(item, kwargs={'pk': 1}))
resp = self.client.get(reverse(item, kwargs={'pk': 1}), follow=True)
self.assertEqual(resp.status_code, 200, item)

redirected_details = ['commproperty-detail', 'commring-detail', ]
Expand Down
26 changes: 13 additions & 13 deletions ringapp/tests/test_ring_souffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def setUp(self) -> None:
def test_L1(self):
self.RP1.has_on_left = True
self.RP1.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP2.refresh_from_db()
self.assertEqual(self.RP2.has_on_left, True)
self.assertIsNone(self.RP2.has_on_right)

def test_L1_backward(self):
self.RP2.has_on_left = False
self.RP2.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP1.refresh_from_db()
self.assertEqual(self.RP2.has_on_left, False)
self.assertIsNone(self.RP2.has_on_right)
Expand All @@ -59,7 +59,7 @@ def test_L1_bothsides(self):
self.RP1.has_on_left = True
self.RP1.has_on_right = True
self.RP1.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP2.refresh_from_db()
self.assertEqual(self.RP2.has_on_left, True)
self.assertEqual(self.RP2.has_on_right, True)
Expand All @@ -69,7 +69,7 @@ def test_L2(self):
self.RP4.has_on_left = True
self.RP3.save()
self.RP4.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP5.refresh_from_db()
self.assertEqual(self.RP5.has_on_left, True)

Expand All @@ -78,35 +78,35 @@ def test_L2_negative(self):
self.RP5.has_on_left = False
self.RP3.save()
self.RP5.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP4.refresh_from_db()
self.assertEqual(self.RP4.has_on_left, False)

def test_l3_1(self):
self.RP6.has_on_left = True
self.RP6.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP7.refresh_from_db()
self.assertEqual(self.RP7.has_on_left, True)

def test_l3_2(self):
self.RP6.has_on_left = False
self.RP6.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP7.refresh_from_db()
self.assertEqual(self.RP7.has_on_left, False)

def test_l3_3(self):
self.RP7.has_on_left = True
self.RP7.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP6.refresh_from_db()
self.assertEqual(self.RP6.has_on_left, True)

def test_l3_4(self):
self.RP7.has_on_left = False
self.RP7.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RP6.refresh_from_db()
self.assertEqual(self.RP6.has_on_left, False)

Expand All @@ -130,7 +130,7 @@ def setUp(self) -> None:
def test_L1_dim(self):
self.RP1.has_on_left = True
self.RP1.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
self.RD1.refresh_from_db()
self.assertEqual(self.RD1.left_dimension, '1')

Expand All @@ -140,7 +140,7 @@ def test_L1_dim_conflict(self):
self.RD1.left_dimension = '2'
self.RD1.save()
with self.assertRaises(CommandError):
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)


class RingSubsetTest(TestCase):
Expand All @@ -161,7 +161,7 @@ def setUp(self) -> None:
def test_L1_subset(self):
self.RP1.has_on_left = True
self.RP1.save()
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)
rs1 = RingSubset.objects.get(ring=self.ring, subset_type=self.S1)
self.assertEqual(rs1.subset, '1')

Expand All @@ -171,5 +171,5 @@ def test_L1_subset_conflict(self):
RingSubset.objects.create(ring=self.ring, subset_type=self.S1, subset='2')

with self.assertRaises(CommandError):
call_command('process_ring', self.ring.id, record=True)
call_command('process_ring', self.ring.id, record=True, reload_logic=True)

1 change: 1 addition & 0 deletions ringapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
path('people/', TemplateView.as_view(template_name='ringapp/people.html'), name='people'),
path('resources/', TemplateView.as_view(template_name='ringapp/resources.html'), name='resources'),
path('contribute/', web.views.SuggestionView.as_view(), name='contribute'),
path('contributors/', TemplateView.as_view(template_name='ringapp/contributors.html'), name='contributors'),
path('inspiration/', views.inspiration_view, name='inspiration'),
path('bibliography/', views.CitationList.as_view(), name='bibliography'),
path('cite/', views.citeview, name='cite'),
Expand Down
3 changes: 2 additions & 1 deletion ringapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,11 @@ def get_context_data(self, **kwargs):
ring = Ring.objects.get(id=kwargs['pk'])
try:
tname = f'dart_data/{tag("RING", ring.id)}_details.html'
print(tname)
render(self.request, tname)
self.template_name = tname
except TemplateDoesNotExist:
self.template_name = 'dart_data/no_expanded_details.html'
self.template_name = 'ringapp/no_expanded_details.html'

context['ring'] = ring

Expand Down
2 changes: 1 addition & 1 deletion web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class SuggestionView(RatelimitMixin, SuccessMessageMixin, CreateView):
model = Suggestion
template_name = 'dart_data/contribute.html'
template_name = 'ringapp/contribute.html'
success_url = '/contribute/'
fields = ['object_type', 'name', 'description']
success_message = "Thanks... we'll look into that %(object_display)s suggestion!"
Expand Down

0 comments on commit c083679

Please sign in to comment.