Esempio n. 1
0
 def post(self, *args, **kwargs):
     if options.team_sharing:
         """ Creates a new text share """
         name = self.get_argument("name", "")
         content = self.get_argument("content", "")
         user = self.get_current_user()
         if 0 < len(name) and 0 < len(content):
             teams = []
             if user.is_admin():
                 teamval = self.get_argument("team_uuid", "")
                 if teamval == "all":
                     teams = Team.all()
                 elif teamval != "":
                     teams = [Team.by_uuid(teamval)]
             else:
                 teams = [user.team]
             for team in teams:
                 paste = PasteBin(team_id=team.id)
                 paste.name = name
                 paste.contents = content
                 self.dbsession.add(paste)
                 self.event_manager.team_paste_shared(user, team, paste)
             self.dbsession.commit()
             if user.is_admin():
                 self.redirect("/admin/view/pastebin")
             else:
                 self.redirect("/user/share/pastebin")
         else:
             self.render(
                 "pastebin/create.html",
                 errors=["Missing name or content"],
                 user=user,
             )
     else:
         self.redirect("/404")
Esempio n. 2
0
 def post(self, *args, **kwargs):
     ''' Creates a new text share '''
     name = self.get_argument("name", '')
     content = self.get_argument("content", '')
     if 0 < len(name) and 0 < len(content):
         user = self.get_current_user()
         paste = PasteBin(team_id=user.team.id)
         paste.name = name
         paste.contents = content
         self.dbsession.add(paste)
         self.dbsession.commit()
         self.event_manager.team_paste_shared(user, paste)
         self.redirect('/user/share/pastebin')
     else:
         self.render('pastebin/create.html',
                     errors=["Missing name or content"])
Esempio n. 3
0
 def get(self, *args, **kwargs):
     if options.team_sharing:
         """ AJAX // Retrieves a paste from the database """
         paste_uuid = self.get_argument("paste_uuid")
         user = self.get_current_user()
         paste = PasteBin.by_uuid(paste_uuid)
         if user.is_admin():
             self.render("pastebin/display.html",
                         errors=None,
                         paste=paste,
                         nocreate=True)
         elif paste is None or paste not in user.team.pastes:
             self.render(
                 "pastebin/display.html",
                 errors=["Paste does not exist."],
                 paste=None,
                 nocreate=None,
             )
         else:
             self.render("pastebin/display.html",
                         errors=None,
                         paste=paste,
                         nocreate=False)
     else:
         self.redirect("/404")
Esempio n. 4
0
 def post(self, *args, **kwargs):
     ''' Creates a new text share '''
     name = self.get_argument("name", '')
     content = self.get_argument("content", '')
     if 0 < len(name) and 0 < len(content):
         user = self.get_current_user()
         paste = PasteBin(team_id=user.team.id)
         paste.name = name
         paste.contents = content
         self.dbsession.add(paste)
         self.dbsession.commit()
         self.event_manager.team_paste_shared(user, paste)
         self.redirect('/user/share/pastebin')
     else:
         self.render('pastebin/create.html',
                     errors=["Missing name or content"])
Esempio n. 5
0
 def post(self, *args, **kwargs):
     ''' AJAX // Delete a paste object from the database '''
     paste = PasteBin.by_uuid(self.get_argument("uuid", ""))
     user = self.get_current_user()
     if paste is not None and paste in user.team.pastes:
         self.dbsession.delete(paste)
         self.dbsession.commit()
     self.redirect("/user/share/pastebin")
Esempio n. 6
0
 def post(self, *args, **kwargs):
     ''' AJAX // Delete a paste object from the database '''
     paste = PasteBin.by_uuid(self.get_argument("uuid", ""))
     user = self.get_current_user()
     if paste is not None and paste in user.team.pastes:
         self.dbsession.delete(paste)
         self.dbsession.commit()
     self.redirect("/user/share/pastebin")
 def get(self, *args, **kwargs):
     ''' AJAX // Retrieves a paste from the database '''
     paste_uuid = self.get_argument("paste_uuid")
     user = self.get_current_user()
     paste = PasteBin.by_uuid(paste_uuid)
     if paste is None or paste not in user.team.pastes:
         self.render("pastebin/display.html", errors=["Paste does not exist."], paste=None)
     else:
         self.render("pastebin/display.html", errors=None, paste=paste)
Esempio n. 8
0
 def post(self, *args, **kwargs):
     if options.team_sharing:
         """ Creates a new text share """
         name = self.get_argument("name", "")
         content = self.get_argument("content", "")
         if 0 < len(name) and 0 < len(content):
             user = self.get_current_user()
             paste = PasteBin(team_id=user.team.id)
             paste.name = name
             paste.contents = content
             self.dbsession.add(paste)
             self.dbsession.commit()
             self.event_manager.team_paste_shared(user, paste)
             self.redirect("/user/share/pastebin")
         else:
             self.render("pastebin/create.html",
                         errors=["Missing name or content"])
     else:
         self.redirect("/404")
Esempio n. 9
0
 def get(self, *args, **kwargs):
     ''' AJAX // Retrieves a paste from the database '''
     paste_uuid = self.get_argument("paste_uuid")
     user = self.get_current_user()
     paste = PasteBin.by_uuid(paste_uuid)
     if paste is None or paste not in user.team.pastes:
         self.render("pastebin/display.html",
                     errors=["Paste does not exist."],
                     paste=None)
     else:
         self.render("pastebin/display.html", errors=None, paste=paste)
Esempio n. 10
0
 def get(self, *args, **kwargs):
     ''' AJAX // Retrieves a paste from the database '''
     paste_uuid = self.get_argument("paste_uuid")
     user = self.get_current_user()
     paste = PasteBin.by_uuid(paste_uuid)
     if user.has_permission(ADMIN_PERMISSION):
         self.render("pastebin/display.html", errors=None, paste=paste, nocreate=True)
     elif paste is None or paste not in user.team.pastes:
         self.render("pastebin/display.html",
                     errors=["Paste does not exist."],
                     paste=None, nocreate=None
                     )
     else:
         self.render("pastebin/display.html", errors=None, paste=paste, nocreate=False)
Esempio n. 11
0
 def post(self, *args, **kwargs):
     if options.team_sharing:
         """ AJAX // Delete a paste object from the database """
         paste = PasteBin.by_uuid(self.get_argument("uuid", ""))
         user = self.get_current_user()
         if user.is_admin():
             self.dbsession.delete(paste)
             self.dbsession.commit()
             self.redirect("/admin/view/pastebin")
             return
         if paste is not None and paste in user.team.pastes:
             self.dbsession.delete(paste)
             self.dbsession.commit()
         self.redirect("/user/share/pastebin")
     else:
         self.redirect("/404")
Esempio n. 12
0
 def post(self, *args, **kwargs):
     if options.team_sharing:
         ''' AJAX // Delete a paste object from the database '''
         paste = PasteBin.by_uuid(self.get_argument("uuid", ""))
         user = self.get_current_user()
         if user.is_admin():
             self.dbsession.delete(paste)
             self.dbsession.commit()
             self.redirect("/admin/view/pastebin")
             return
         if paste is not None and paste in user.team.pastes:
             self.dbsession.delete(paste)
             self.dbsession.commit()
         self.redirect("/user/share/pastebin")
     else:
         self.redirect("/404")
Esempio n. 13
0
 def get(self, *args, **kwargs):
     if options.team_sharing:
         ''' AJAX // Retrieves a paste from the database '''
         paste_uuid = self.get_argument("paste_uuid")
         user = self.get_current_user()
         paste = PasteBin.by_uuid(paste_uuid)
         if user.is_admin():
             self.render("pastebin/display.html", errors=None, paste=paste, nocreate=True)
         elif paste is None or paste not in user.team.pastes:
             self.render("pastebin/display.html",
                         errors=["Paste does not exist."],
                         paste=None, nocreate=None
                         )
         else:
             self.render("pastebin/display.html", errors=None, paste=paste, nocreate=False)
     else:
         self.redirect("/404")