Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cnk's full-sized avatar

Cynthia Kiser cnk

View GitHub Profile
require 'RMagick'
class BackgroundImage < ActiveRecord::Base
attr_accessible :parent_id, :uploaded_data, :filename
has_one :child, :class_name => "BackgroundImage", :foreign_key => :parent_id
# You may want to pass other options to has_attachment.
# See the attachment_fu README.
has_attachment :content_type => :image,
.
----------------------------------------------------------------------
Ran 1 test in 0.412s
OK
BUT if I change from force_authentication to the login line,
403
{'detail': 'CSRF Failed: CSRF cookie not set.'}
manage.py test --keepdb course_builder.multiple_choice_question.tests2
Using existing test database for alias 'default'...
<class 'dict'>
200
{'correct_answer': {'answer_text': '1', 'correct_answer': '/course_materials/course0/multiple_choice_answers/90/'},
'student_answer': {'is_answer_correct': True, 'answer': '/course_materials/course0/multiple_choice_answers/90/'}}
.
----------------------------------------------------------------------
Ran 1 test in 0.417s
Vagrant.configure(2) do |config|
config.vm.box = "boxcutter/ubuntu1604"
config.vm.hostname = "dev-#{ENV['USER']}"
config.vm.network "private_network", ip: "10.1.99.100"
config.vm.provider "virtualbox" do |vbox|
vbox.name = "dev-#{ENV['USER']}"
end
config.vm.synced_folder "./", "/srv/salt/"
config.vm.provision :salt do |salt|
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
in update view
serializer not valid
{'title': ['This field may not be blank.']}
last_answer = StudentNumericAnswer.objects.filter(numeric_question=question_id,
student=request.user.id).order_by('updated_at').last()
if request.method == 'GET':
if not last_answer:
return Response(status=status.HTTP_404_NOT_FOUND)
data = StudentNumericAnswerSerializer(last_answer, context={'request': request}).data
# CNK cheat and add the correct answer data here for now
if last_answer.is_answer_correct or last_answer.gave_up:
data['correct_answer'] = {'correct_answer': question.correct_answer,
class FooSerializer(rest_serializers.ModelSerializer):
class Meta:
model = MultipleChoiceQuestion
fields = ('id', 'model_name', 'title', 'student_answer_url', 'block_state', 'ready_preview', )
def validate(self, data):
'''Mostly this just shovels data from the request into validated_data. '''
errors = {}
print('in validate initial data is: ', type(self.initial_data))
from django.conf import settings
class DefaultDatabaseRouter(object):
def db_for_read(self, model, **hints):
"""
This is the fall through. If the table isn't found in mk_web_core, it must be here.
"""
if model._meta.app_label in ['accounts', 'materials',]:
return 'mk_web_core'
def permission_denied
@page_args[:title] = "Permission Denied"
@body = "You are not allowed to view the page you have requested. If you believe you should have been able to view that page, please use the contact information in the footer to report this problem."
render 'system/errors', status: 403
end
from django.core.management.base import BaseCommand
from ...jobs import CampusAnnouncementImporter
class Command(BaseCommand):
help = "Imports Campus Announcements."
def handle(self, **options):
importer = CampusAnnouncementImporter()
print(type(CampusAnnouncementImporter))