Пример #1
0
    def run(self):

        user1 = User.query.filter_by(email="*****@*****.**").first()
        youth_group = Group(
            group_name="Youth Felowship",
            group_description="members of ages ranging from 13 to 35",
            creator=user1)
        women_group = Group(
            group_name="Women Felowship",
            group_description="females with children or 20 years and above",
            creator=user1)

        self.db.session.add_all([youth_group, women_group])
        self.db.session.commit()
Пример #2
0
    def make (self, author):
        """
        для работы с формами, туда надо передать некоорое количество данных. 
        все эти данные надо собрать в объкт (одиночку) TemplateParams
        и пользоваться его данными
          
        """
#         logging.info( ' makeTplParametr:: self = ' + str(self))
#         if not hasattr(self, 'autorGroupList'): 

#         logging.info( ' makeTplParametr:: get autorGroupList NOW! = ')
        self.author = author
        groupModel = Group()
#         self.autorGroupList = yield executor.submit( groupModel.grouplistForAutor, self.author.author_id )
        self.autorGroupList = groupModel.grouplistForAutor( self.author.author_id )
Пример #3
0
 def post(self, request):
     """
     """
     user = request.user
     data = request.DATA
     if data.get('name') == 'Default':
         return Response("The 'Default' project name is reserved",
                         status=status.HTTP_409_CONFLICT)
     #Default to creating for the 'user-group'
     if not data.get('owner'):
         data['owner'] = user.username
     elif not Group.check_access(user, data['owner']):
         return failure_response(
             status.HTTP_403_FORBIDDEN,
             "Current User: %s - Cannot assign project for group %s" %
             (user.username, data['owner']))
     serializer = ProjectSerializer(data=data,
                                    context={"user": request.user})
     if serializer.is_valid():
         serializer.save()
         response = Response(serializer.data,
                             status=status.HTTP_201_CREATED)
         return response
     else:
         return Response(serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)
Пример #4
0
 def post(self, request):
     """
     """
     user = request.user
     data = request.DATA
     if data.get('name') == 'Default':
         return Response("The 'Default' project name is reserved",
                         status=status.HTTP_409_CONFLICT)
     #Default to creating for the 'user-group'
     if not data.get('owner'):
         data['owner'] = user.username
     elif not Group.check_access(user, data['owner']):
         return failure_response(
                 status.HTTP_403_FORBIDDEN,
                 "Current User: %s - Cannot assign project for group %s"
                 % (user.username, data['owner']))
     serializer = ProjectSerializer(data=data,
                                    context={"user":request.user})
     if serializer.is_valid():
         serializer.save()
         response = Response(
                 serializer.data,
                 status=status.HTTP_201_CREATED)
         return response
     else:
         return Response(serializer.errors,
                 status=status.HTTP_400_BAD_REQUEST)
Пример #5
0
def fill_groups(faculty_id: int, course: int):
    """
    Fill db with groups in particular faculty and course
    :param faculty_id: faculty id in the university site
    :param course: course number
    """
    page = requests.get("https://rasp.unecon.ru/raspisanie.php", params={"fakultet": faculty_id, "kurs": course})

    if page.status_code == 200:
        soup = BeautifulSoup(page.content, features="html.parser")

        groups = soup.find("div", {"class": "grps"})

        if groups:
            session = Session()
            try:
                for group in groups.find_all("a"):
                    new_group = Group(
                        id=group["href"].split("=")[-1],
                        name=group.string,
                        faculty_id=faculty_id,
                        course=course
                    )
                    session.add(new_group)

                session.commit()
            except Exception as e:
                print(e)
            finally:
                session.close()
    else:
        print(f"{page.url} request failed")
Пример #6
0
    def post(self, group_id=0):
        try:
            author = self.get_current_user() 
    
            groupModel = Group()
    
            groupModel.group_id = int(self.get_argument("id", 0))
            groupModel.group_title = self.get_argument("title")
            groupModel.group_annotation = self.get_argument("annotation")
            groupModel.group_status = self.get_argument("status", 'pbl')                                
            
            rez = yield executor.submit( groupModel.save, author.author_id )
            
            self.redirect("/group_desk_top/" + str(groupModel.group_id))
        except Exception as e:
            logging.info( 'GroupDeskTop POST!!! (Save):: Exception as et = ' + str(e))
#             error = Error ('500', 'что - то пошло не так :-( ')
#             self.render('error.html', error=error, link='/compose', page_name='')
            pageName = 'Редактирование ' + groupModel.group_title
            self.render("group_dt.html", group=group, page_name= pageName, link='group_dt')
Пример #7
0
    def сomposeArticleSave(self, author_id, templateDir, article_pgroipId):
        """
        сохранить статью
        
        """
        try:
            self.artModel.begin()

            article = self.artModel.save(author_id, templateDir)
            logging.info( 'сomposeArticleSave:: author_id = ' + str(author_id))
            logging.info( 'сomposeArticleSave:: article_pgroipId = ' + str(article_pgroipId))
            logging.info( 'сomposeArticleSave:: article.article_id = ' + str(article.article_id))
      
            if int(article_pgroipId) > 0 :
                groupModel = Group()
                groupModel.librarySave(int(author_id), int(article_pgroipId), int(article.article_id), 'W')
                
            self.artModel.commit()                
            return True
        except WikiException as e:   
#             WikiException( ARTICLE_NOT_FOUND )
            logging.info( 'сomposeArticleSave:: e = ' + str(e))
            return False
 def post(self, request):
     user = request.user
     data = request.data
     # Default to creating for the 'user-group'
     if not data.get("owner"):
         data["owner"] = user.username
     elif not Group.check_access(user, data["owner"]):
         return failure_response(
             status.HTTP_403_FORBIDDEN,
             "Current User: %s - Cannot assign project for group %s" % (user.username, data["owner"]),
         )
     serializer = ProjectSerializer(data=data, context={"request": request})
     if serializer.is_valid():
         serializer.save()
         response = Response(serializer.data, status=status.HTTP_201_CREATED)
         return response
     else:
         return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)