
    7hm
                         d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ  ede      Zej#                  d	d
g      e	d               Zy)    )	OldPapers)ObjectId)requestjsonify	Blueprint)jwt_required)Course)UserCoursePurchase)datetime
old_papersz/get_old_papers_listPOST)methodsc            
         	 t        t        dd       } | st        ddd      dfS t        j                  j	                  d      }|r| st        ddd      dfS t        j                  t        |      d	
      j                         }d}d}| rt        j                  t        |       |j                  d	      j                         }|rJd	}|j                  }|j                  r0t        j                         |j                  z
  j                  |kD  rd	}|st        ddd      dfS |rt        ddd      dfS t!        j                  t        |      d	      }|D cg c]^  }t#        |j                        |j$                  |j                  |j&                  |j(                  |j*                  j-                         d` }	}t        d|||	d      dfS c c}w # t.        $ r#}
t        dt#        |
      d      dfcY d }
~
S d }
~
ww xY w)Nuser_idFzInvalid user id)statusmessagei  	course_idz"course_id and user_id are requiredi     )idr   r   )r   r   r   zCourse not purchasedi  zCourse access has expired)r   r   )paper_idpaper_titledurationvideo_file_pathnumber_of_questionscreated_dateT)r   is_purchased
is_expireddata   i  )getattrr   r   jsongetr	   objectsr   firstr
   r   r   purchase_dater   utcnowdaysr   strr   content_file_pathr   r   	isoformat	Exception)r   r   course_detailsr   r   purchaseexpiry_daysr   paperresultes              -/var/www/html/eduruby.in/routes/old_papers.pyget_old_papers_listr3      s
   3B'9d3e8IJKSPPLL$$[1	e8\]^`ccc (9*=aHNNP
)11 )(++ eg	 
  ,55))x/@8CYCY/Y._._bm.m!"J e8NOPRUUUe8STUWZZZ&&)1DQO
 "#  EHH ,,$66#(#<#<!..88:
 # # ($	
 
  	#   B%CF;<cAABsH   "G 2G C
G #G 5$G A#G<G G 	HG<6H<HN)models.old_papers_modelr   bsonr   flaskr   r   r   utils.jwt_servicer   models.courser	   #models.user_course_purchase_historyr
   r   __name__old_papers_bprouter3        r2   <module>r?      sX    -  - - *   B ,1+fX>4B  ?4Br>   