def update_number_views(self,text_material_id):
		text_material_instance = self.get_text_material()
		if text_material_instance:
			text_instance = self.get_text(text_material_instance)
			text_management().update_number_views(text_instance)
			return True
		return False		
Beispiel #2
0
 def update_number_views(self, text_material_id):
     text_material_instance = self.get_text_material()
     if text_material_instance:
         text_instance = self.get_text(text_material_instance)
         text_management().update_number_views(text_instance)
         return True
     return False
Beispiel #3
0
	def post(self):
		user = self.get_user_type()		
		if user == user_type.visitor:
			self.redirect('/')
		elif user == user_type.student:
			self.redirect('/')
		elif user == user_type.tutor:			
			if not 'text_material_id' in self.session:
				self.session['text_material_id'] = None
			if not 'extension' in self.session:
				self.session['extension'] = None
			if not 'size' in self.session:
				self.session['size'] = None
			title = self.request.get('title',None)
			description = self.request.get('description',None)
			level = int(self.request.get('level',None))
			unit_id = self.request.get('unit',None)
			subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
			if unit_id:
				unit_id = int(unit_id)
			topic = title
			tags = self.request.get_all('tags',None)				  			
			tutor_key = tutor_management().get_tutor(self.session['user-id']).key()
			text_material_id = self.request.get('text_material_id',None)			
			if text_material_id:
				text_material_id = int(text_material_id)
				text_material_instance = text_material_management().get_text_material(text_material_id)
				topic_ins = topic_management().get_topic(text_material_instance.topic.key().id())				
				topic_management().modify(subject.key(),topic_ins.key(),topic)
				text_ins = text_management().get_text(text_material_instance.text.key().id())							
				text_management().modify(text_ins.key(),description,text_ins.size)
				text_material_management().modify(text_material_instance.key(),text_ins.key(),level,unit_id,subject.key(),topic_ins.key(),tags,tutor_key)
			else:							
				size = self.session['size']
				size = int(size)
				ext_format = self.session['extension']
				topic_key = topic_management().add(subject.key(),topic)				
				text_id = self.session['text-id']
				if text_id:
					text_id=int(text_id)
				self.session['text-id'] = None
				self.session['text_material_id'] = None
				text_instance = text_management().get_text(text_id)	
				text_key = text_management().add(text_instance.key(),description,ext_format,size,0)
				text_material_management().add(text_key,level,unit_id,subject.key(),topic_key,tags,tutor_key)		
			sleep(0.1)					
			self.redirect('/admin_text')       	
		else:
			self.redirect('/')
Beispiel #4
0
    def post(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
        elif user == user_type.student:
            self.redirect('/')
        elif user == user_type.tutor:
            upload_text = self.get_uploads()[0]
            blob_info = upload_text
            text_properties = blob_info.properties()
            text_info = blob_info.get(blob_info.key())
            text_name = text_info.filename
            extension = os.path.splitext(text_name)[-1]
            extension = extension[1:]
            self.session['extension'] = extension
            self.session['name_file'] = text_name
            self.session['size'] = text_info.size
            text_format_allowed = ['pdf']
            if extension in text_format_allowed:
                text_instance = text_management().add_content(blob_info)
                self.session['text-id'] = text_instance.id()
                self.response.write('{"status":"success"}')
            else:
                self.response.write('{"status":"error"}')

        else:
            self.redirect('/')
Beispiel #5
0
	def post(self):
		user = self.get_user_type()
		if user == user_type.visitor:
			self.redirect('/')
		elif user == user_type.student:
			self.redirect('/')
		elif user == user_type.tutor:				
			upload_text = self.get_uploads()[0]			
			blob_info = upload_text				
			text_properties = blob_info.properties()			
			text_info = blob_info.get(blob_info.key())
			text_name = text_info.filename				
			extension = os.path.splitext(text_name)[-1]			
			extension = extension[1:]
			self.session['extension'] = extension
			self.session['name_file'] = text_name						
			self.session['size'] = text_info.size
			text_format_allowed = ['pdf']
			if extension in text_format_allowed:			 	
			 	text_instance = text_management().add_content(blob_info)	
			 	self.session['text-id'] = text_instance.id()				
				self.response.write('{"status":"success"}')								
			else:					
			 	self.response.write('{"status":"error"}')				
			
		else:
			self.redirect('/')
Beispiel #6
0
 def get_text(self, text_material_instance):
     return text_management().get_text(
         text_material_instance.text.key().id())
Beispiel #7
0
 def get_number_views(self, text_material_id):
     text_material_instance = self.get_text_material(text_material_id)
     if text_material_instance:
         text_instance = self.get_text(text_material_instance)
         return text_management().get_number_views(text_instance)
     return None
Beispiel #8
0
 def get(self):
     user = self.get_user_type()
     if user == user_type.visitor:
         self.redirect('/')
     elif user == user_type.student:
         text_material_id = self.request.get('text_material_id', None)
         if not text_material_id:
             self.redirect('/explorer')
         text_instance = None
         text_material_instance = None
         text_material_id = int(text_material_id)
         if text_material_id:
             text_material_instance = text_material_management(
             ).get_text_material(text_material_id)
         if not text_material_instance:
             self.redirect('/explorer')
         else:
             student_instance = student_management().find_key(
                 self.session['user-id'])
             text_instance = text_material_management().get_text(
                 text_material_instance)
             text_management().update_number_views(text_instance)
             list_tag_text_supported = ['pdf']
             list_tag_embedded_supported = ['pdf']
             #list_tag_object_supported = ['swf']
             tformat = text_instance.ext_format
             tinfo = {}
             tinfo['format'] = tformat
             tinfo['tutor'] = (tutor_management().get_tutor(
                 text_material_instance.tutor.key().id())).first
             tinfo['topic'] = (topic_management().get_topic(
                 text_material_instance.topic.key().id())).name
             tinfo['content'] = text_instance.content
             tinfo['subject'] = (subject_management().get_subject(
                 text_material_instance.subject.key().id())).name
             tinfo['description'] = text_instance.description
             tinfo['tags'] = text_material_instance.tags
             template_values = {
                 "user": "******",
                 "header_welcome": "",
                 "header_tutor": "",
                 "tinfo": tinfo,
                 'embbeded_supported': list_tag_embedded_supported,
                 'text_supported': list_tag_text_supported,
                 "student_name": student_instance.first
                 #"object_supported":list_tag_object_supported
             }
             self.response.write(viewtext_template.render(template_values))
     elif user == user_type.tutor:
         text_material_id = int(self.request.get('text_material_id'))
         text_instance = None
         text_material_instance = None
         if text_material_id:
             text_material_instance = text_material_management(
             ).get_text_material(text_material_id)
         if not text_material_instance:
             self.redirect('/home')
         else:
             tutor_id = self.session['user-id']
             tutor_key = tutor_management().get_tutor(tutor_id).key()
             tutor_instance = tutor_management().get_tutor(tutor_id)
             text_instance = text_material_management().get_text(
                 text_material_instance)
             list_text_supported = ['pdf']
             tformat = text_instance.ext_format
             #list_tag_object_supported = ['swf']
             tinfo = {}
             tinfo['format'] = tformat
             tinfo['tutor'] = (tutor_management().get_tutor(
                 text_material_instance.tutor.key().id())).first
             tinfo['topic'] = (topic_management().get_topic(
                 text_material_instance.topic.key().id())).name
             tinfo['content'] = text_instance.content
             tinfo['subject'] = (subject_management().get_subject(
                 text_material_instance.subject.key().id())).name
             tinfo['description'] = text_instance.description
             tinfo['tags'] = text_material_instance.tags
             #blob_info = BlobInfo.get(text_instance.content.key())
             template_values = {
                 "user": "******",
                 "header_welcome": "",
                 "header_tutor": "",
                 "tinfo": tinfo,
                 "tutor_name": tutor_instance.first,
                 #"object_supported":list_tag_object_supported
             }
             #self.response.headers['Content-Type'] = 'video/avi'
             self.response.write(viewtext_template.render(template_values))
     else:
         self.redirect('/home')
Beispiel #9
0
	def get(self):
		user = self.get_user_type()
		if user == user_type.visitor:
			self.redirect('/')
		elif user == user_type.student:			
			if not 'text-id' in self.session:
				self.session['text-id'] = None
			text_content = ''
			if self.session['text-id'] == None:
				self.redirect('/home')

			try:
				text_id = int(self.session['text-id'])				
				text_instance = text_management().get_text(text_id)
				text_content = text_instance.content
			except ValueError:									
				text_content = ''		
			except TypeError:
				text_id = 0	

			template_values={
			    "user":"******",   
			    "header_welcome":"",
			    "header_user":"",
			    "text_content":text_content			    
			}
			self.response.write(data_text_template.render(template_values))  			
		elif user == user_type.tutor:			
			text_material_id = self.request.get('text_material_id',None)
			if not 'text-id' in self.session:
				self.session['text-id'] = None
			if not 'name_file' in self.session:
				self.session['name_file'] = None	
			if not 'name_file' in self.session:
				self.session['extension'] = None		
			
			if self.session['text-id'] == None and self.session['name_file'] == None and text_material_id is None:
				self.redirect('/home')
											
			text_format_allowed = ['pdf']

			tutor_id = self.session['user-id']
			tutor_key = tutor_management().get_tutor(tutor_id).key()
			tutor_instance = tutor_management().get_tutor(tutor_id)
				
			if text_material_id:				
				text_material_id = int(text_material_id)
				text_material_instance = text_material_management().get_text_material(text_material_id)
				text_instance = text_material_management().get_text(text_material_instance)
				tinfo = {}                                
				tinfo['topic'] = text_material_instance.topic
				tinfo['description'] = text_instance.description
				tinfo['level'] = text_material_instance.level
				tinfo['tags'] = text_material_instance.tags
				text_content = text_instance.content
				subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
				subject_units = unit_management().get_all_units_of_subject(subject.key())
				list_units = []
				for unit in subject_units:
					uinfo = {}
					uinfo['name'] = unit.name
					uinfo['id'] = unit.key().id()
					list_units.append(uinfo)				
				template_values = {
					"user":"******",
					"tinfo":tinfo,
					"edit":True,
					"text_content":text_content,
					"list_units":list_units,
					"name_file":self.session['name_file'],
					"tutor_name": tutor_instance.first,
					"text_material_id":text_material_id
				}				
			else:
				text_content = ''
				try:
					text_id = int(self.session['text-id'])				
					text_instance = text_management().get_text(text_id)
					text_content = text_instance.content
				except ValueError:									
					text_content = ''		
				except TypeError:
					text_id = 0
				subject = subject_management().get_subject_by_name('Programacion Orientada a Objetos')
				subject_units = unit_management().get_all_units_of_subject(subject.key())
				list_units = []
				for unit in subject_units:
					uinfo = {}
					uinfo['name'] = unit.name
					uinfo['id'] = unit.key().id()
					list_units.append(uinfo)
				template_values={
					"user":"******",   
					"header_welcome":"",
					"edit":False,
					"header_tutor":"",
					"text_content":text_content,
					"list_units":list_units,
					"name_file":self.session['name_file'],
					"tutor_name": tutor_instance.first,
					"text_material_id":""
				}        
			self.response.write(data_text_template.render(template_values))			
		else:
			self.redirect('/')
	def get_text(self,text_material_instance):				
		return text_management().get_text(text_material_instance.text.key().id())
	def get_number_views(self,text_material_id):
		text_material_instance = self.get_text_material(text_material_id)
		if text_material_instance:
			text_instance =  self.get_text(text_material_instance)
			return text_management().get_number_views(text_instance)
		return None
Beispiel #12
0
    def get(self):
        user = self.get_user_type()
        if user == user_type.visitor:
            self.redirect('/')
        elif user == user_type.student:
            text_material_id = self.request.get('text_material_id',None)
            if not text_material_id:
                self.redirect('/explorer')
            text_instance = None        
            text_material_instance = None
            text_material_id = int(text_material_id)
            if text_material_id:                
                text_material_instance = text_material_management().get_text_material(text_material_id)
            if not text_material_instance:
                self.redirect('/explorer')                
            else:             
            	student_instance = student_management().find_key(self.session['user-id'])
                text_instance = text_material_management().get_text(text_material_instance)                        
                text_management().update_number_views(text_instance)
                list_tag_text_supported = ['pdf']
                list_tag_embedded_supported = ['pdf']
                #list_tag_object_supported = ['swf'] 
                tformat = text_instance.ext_format                
                tinfo = {}
                tinfo['format'] = tformat
                tinfo['tutor'] = (tutor_management().get_tutor(text_material_instance.tutor.key().id())).first
                tinfo['topic'] = (topic_management().get_topic(text_material_instance.topic.key().id())).name                    
                tinfo['content'] = text_instance.content
                tinfo['subject'] = (subject_management().get_subject(text_material_instance.subject.key().id())).name
                tinfo['description'] = text_instance.description
                tinfo['tags'] = text_material_instance.tags
                template_values={
                    "user":"******",   
                    "header_welcome":"",
                    "header_tutor":"",                
                    "tinfo":tinfo,            
                    'embbeded_supported':list_tag_embedded_supported,
                    'text_supported':list_tag_text_supported,
                    "student_name":student_instance.first
                    #"object_supported":list_tag_object_supported
                }                                           
                self.response.write(viewtext_template.render(template_values))            
        elif user == user_type.tutor:
            text_material_id = int(self.request.get('text_material_id'))
            text_instance = None        
            text_material_instance = None
            if text_material_id:                
                text_material_instance = text_material_management().get_text_material(text_material_id)
            if not text_material_instance:
                self.redirect('/home')                
            else:
				tutor_id = self.session['user-id']
				tutor_key = tutor_management().get_tutor(tutor_id).key()
				tutor_instance = tutor_management().get_tutor(tutor_id)
				text_instance = text_material_management().get_text(text_material_instance)                                                
				list_text_supported = ['pdf']
				tformat = text_instance.ext_format            
				#list_tag_object_supported = ['swf']
				tinfo = {}
				tinfo['format'] = tformat
				tinfo['tutor'] = (tutor_management().get_tutor(text_material_instance.tutor.key().id())).first
				tinfo['topic'] = (topic_management().get_topic(text_material_instance.topic.key().id())).name                    
				tinfo['content'] = text_instance.content
				tinfo['subject'] = (subject_management().get_subject(text_material_instance.subject.key().id())).name
				tinfo['description'] = text_instance.description
				tinfo['tags'] = text_material_instance.tags
				#blob_info = BlobInfo.get(text_instance.content.key())
				template_values={
					"user":"******",   
					"header_welcome":"",
					"header_tutor":"",                
					"tinfo":tinfo,                                
					"tutor_name": tutor_instance.first,					
					#"object_supported":list_tag_object_supported
				}         
				#self.response.headers['Content-Type'] = 'video/avi'
				self.response.write(viewtext_template.render(template_values))            
        else:
            self.redirect('/home')