Skip to content

Commit a50729c

Browse files
committed
Fix qr code save error
1 parent 2d9cf8d commit a50729c

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

online_test/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__all__ = ('celery_app',)
66

7-
__version__ = '0.30.0'
7+
__version__ = '0.31.1'

yaksh/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,8 +3368,10 @@ def generate_image(self, content):
33683368
os.makedirs(qr_dir)
33693369
path = os.path.join(qr_dir, f'{self.short_key}.png')
33703370
img.save(path)
3371-
self.image = os.path.join('qrcode', '{0}.png'.format(self.short_key))
3372-
self.activate()
3371+
with open(path, "rb") as qr_file:
3372+
django_file = File(qr_file)
3373+
self.activate()
3374+
self.image.save(os.path.basename(path), django_file, save=True)
33733375

33743376

33753377
class QRcodeHandler(models.Model):

yaksh/templates/yaksh/question.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,10 @@ <h4><u> Solution by teacher</u></h4>
284284
<br />
285285
<div class="row">
286286
<div class="col-md-8">
287-
<p>Upload assignment file for the said question.
288-
<br>
289-
<span class="badge badge-primary">
290-
</u> <strong>You can upload using the file browser below or via the QR code.</strong></u>
291-
</span>
292-
</p>
293287
<div class="dropzone needsclick dz-clickable" id="dropzone_file">
294288
<div class="dz-message needsclick">
295289
<button type="button" class="dz-button">
296-
Drop files here or click to upload.
290+
You can upload using the file browser here or via the QR code.
297291
</button>
298292
</div>
299293
</div>

yaksh/views.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4163,7 +4163,6 @@ def generate_qrcode(request, answerpaper_id, question_id, module_id):
41634163
reverse("yaksh:upload_file", args=[qrcode.short_key])
41644164
)
41654165
qrcode.generate_image(content)
4166-
qrcode.save()
41674166
return redirect(
41684167
reverse(
41694168
'yaksh:skip_question',

0 commit comments

Comments
 (0)