phanterpwa 13.14.4__py3-none-any.whl → 13.14.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
phanterpwa/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  # license: MIT
4
4
 
5
5
  __author__ = "PhanterJR<junior.conex@gmail.com>"
6
- __version__ = "13.14.4"
6
+ __version__ = "13.14.7"
7
7
  __install_requeriments__ = [
8
8
  "psutil",
9
9
  "tornado",
@@ -503,7 +503,6 @@ def check_public_csrf_token(form_identify=None, ignore_locked=True):
503
503
  except SignatureExpired:
504
504
  token_content = None
505
505
  if token_content:
506
- print(token_content)
507
506
  if 'id' in token_content:
508
507
  self.DALDatabase._adapter.reconnect()
509
508
  q = self.DALDatabase(self.DALDatabase.csrf.id == token_content["id"]).select().first()
@@ -1237,7 +1237,7 @@ class RequestAccount(web.RequestHandler):
1237
1237
  'i18n': {'message': self.T('The user was not found')}
1238
1238
  })
1239
1239
  else:
1240
- new_password = temporary_password()
1240
+ new_password = temporary_password(chars="abcdefghijmnpqrstuvxzykABCDEFGHJLMNPQRSTUVXZYK123456789")
1241
1241
  self.Translator_email.direct_translation = self.phanterpwa_language
1242
1242
  keys_formatter = dict(
1243
1243
  app_name=self.projectConfig['PROJECT']['name'],
@@ -2333,7 +2333,7 @@ class RequestAccount(web.RequestHandler):
2333
2333
  'i18n': {'message': message_i18n}
2334
2334
  })
2335
2335
  else:
2336
- new_password = temporary_password()
2336
+ new_password = temporary_password(chars="abcdefghijmnpqrstuvxzykABCDEFGHJLMNPQRSTUVXZYK123456789")
2337
2337
  self.Translator_sms.direct_translation = self.phanterpwa_language
2338
2338
  keys_formatter = dict(
2339
2339
  app_name=self.projectConfig['PROJECT']['name'],
@@ -2490,7 +2490,7 @@ class RequestAccount(web.RequestHandler):
2490
2490
  'i18n': {'message': message_i18n}
2491
2491
  })
2492
2492
  else:
2493
- new_password = temporary_password()
2493
+ new_password = temporary_password(chars="abcdefghijmnpqrstuvxzykABCDEFGHJLMNPQRSTUVXZYK123456789")
2494
2494
  self.Translator_email.direct_translation = self.phanterpwa_language
2495
2495
  keys_formatter = dict(
2496
2496
  app_name=self.projectConfig['PROJECT']['name'],
@@ -131,7 +131,6 @@ class Messages(web.RequestHandler):
131
131
  internal_messages = []
132
132
  for x in s_messages:
133
133
  dict_send = json.loads(x.as_json())
134
- print(dict_send)
135
134
  dict_send['recipients_and_read_status'] = [
136
135
  [
137
136
  "{0} {1} <{2}>".format(
@@ -443,7 +443,6 @@ class PhanterpwaGalleryImageBytes(object):
443
443
  nome_da_imagem = self.nome_da_imagem
444
444
  nome_do_arquivo, extensao = os.path.splitext(nome_da_imagem)
445
445
  im = PILImage.open(self.imageBytes)
446
- print(im.getdata())
447
446
  jpeg_image_buffer = io.BytesIO()
448
447
  if extensao.lower() == '.png' or self.force_png:
449
448
  self.extensao = 'png'
@@ -425,6 +425,7 @@ class Select(Widget):
425
425
  self._icon_confirm = parameters.get("icon_confirm", I(_class="fas fa-check"))
426
426
  self._icon_check = parameters.get("icon_check", I(_class="fas fa-check"))
427
427
  self._on_click_new = parameters.get("on_click_new_button", None)
428
+ self._on_change = parameters.get("on_change", None)
428
429
  self.set_z_index(parameters.get("z_index", None))
429
430
  self.set_recalc_on_scroll(parameters.get("recalc_on_scroll", True))
430
431
  xml_icon = ""
@@ -679,6 +680,8 @@ class Select(Widget):
679
680
  p.removeClass("has_value")
680
681
  p.find("input").trigger("keyup")
681
682
  self.validate()
683
+ if callable(self._on_change):
684
+ self._on_change(self)
682
685
 
683
686
  def _on_click_label(self, el):
684
687
  el = jQuery(el)
@@ -3062,7 +3065,6 @@ class Inert(Widget):
3062
3065
  class IntegerMinusPlus(Widget):
3063
3066
  def __init__(self, identifier, **parameters):
3064
3067
  self._label = parameters.get("label", None)
3065
- console.log(parameters, parameters.get("label"), parameters["label"])
3066
3068
  self._name = parameters.get("name", None)
3067
3069
  self._value = masks.stringFilter(parameters.get("value", 0))
3068
3070
  if self._value == "":
@@ -3190,7 +3192,6 @@ class IntegerMinusPlus(Widget):
3190
3192
  window.PhanterPWA.get_widget(self._id_wg_input).start()
3191
3193
 
3192
3194
 
3193
-
3194
3195
  class CheckBox(Widget):
3195
3196
  def __init__(self, identifier, **parameters):
3196
3197
  self._label = parameters.get("label", None)
@@ -4832,6 +4833,54 @@ class TableFooterPagination(Widget):
4832
4833
  las.off("click.btn_pagination").on("click.btn_pagination", lambda: self._on_click_buttom_page(this))
4833
4834
 
4834
4835
 
4836
+ class File(Widget):
4837
+ def __init__(self, identifier, **parameters):
4838
+ self._name = parameters.get("name", None)
4839
+ self._value = parameters.get("value", None)
4840
+ self._icon = parameters.get("icon", None)
4841
+ self._form = parameters.get("form", None)
4842
+ self._nocache = parameters.get("nocache", False)
4843
+ self._accept_types = parameters.get("accept_types", "application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.oasis.opendocument.text")
4844
+ self.identifier = identifier
4845
+ self.__child_html = DIV(
4846
+ _id="phanterpwa-widget-file-wrapper-{0}".format(identifier),
4847
+ _class="phanterpwa-widget-file-wrapper"
4848
+ )
4849
+ self.iniciate = False
4850
+ if "_class" in parameters:
4851
+ parameters["_class"] = "{0}{1}".format(parameters["_class"], " phanterpwa-widget-file")
4852
+ else:
4853
+ parameters['_class'] = "phanterpwa-widget-file"
4854
+ if self._nocache and (self._value is not "" and self._value is not None):
4855
+ now = __new__(Date().getTime())
4856
+ self._value = "{0}?nocache={1}".format(self._value, now)
4857
+ Widget.__init__(self, identifier, self.__child_html, **parameters)
4858
+
4859
+ def _binds(self):
4860
+ GalleryInput(
4861
+ "#phanterpwa-widget-file-wrapper-{0}".format(self.identifier),
4862
+ **{
4863
+ "name": self._name,
4864
+ "cutter": self._cutter,
4865
+ "current_image": self._value,
4866
+ "img_name": "File_{0}".format(self.identifier),
4867
+ "is_image": False,
4868
+ "width": 150,
4869
+ "height": 150,
4870
+ "data_view": self._data_view,
4871
+ "accept_types": self._accept_types
4872
+ }
4873
+ )
4874
+
4875
+ def reload(self):
4876
+ if not self.iniciate:
4877
+ self.iniciate = True
4878
+ self.start()
4879
+
4880
+ def start(self):
4881
+ self._binds()
4882
+
4883
+
4835
4884
  class Image(Widget):
4836
4885
  def __init__(self, identifier, **parameters):
4837
4886
  self._name = parameters.get("name", None)
@@ -4897,6 +4946,7 @@ class GalleryInput():
4897
4946
  "button-upload": I(_class="fas fa-cloud-upload-alt").xml(),
4898
4947
  "width": 190,
4899
4948
  "height": 200,
4949
+ "is_image": True,
4900
4950
  "view-width": None,
4901
4951
  "view-height": None,
4902
4952
  "cutter": False,
@@ -4978,15 +5028,49 @@ class GalleryInput():
4978
5028
  lambda: inputChange(this, self.config)
4979
5029
  )
4980
5030
 
5031
+ def getNewFile(self):
5032
+ def inputChange(el):
5033
+ blob = jQuery(el)[0].files
5034
+ fileslength = blob.length
5035
+ for i in range(fileslength):
5036
+ img_type = blob[i]['type']
5037
+ img_name = blob[i]['name']
5038
+ self.config["img_type"] = img_type
5039
+ self.config["img_name"] = img_name
5040
+ def onloadend(reader, img_name, img_type):
5041
+ self.fileChoiced()
5042
+ reader = __new__(FileReader())
5043
+ reader.readAsDataURL(blob[0])
5044
+ reader.onloadend = lambda: onloadend(reader, img_name, img_type)
5045
+
5046
+ el_input = jQuery("#phanterpwa-gallery-input-file-{0}".format(self.namespace))
5047
+ el_input.trigger(
5048
+ "click"
5049
+ ).off(
5050
+ "change.phanterpwa_gallery_input_{0}".format(self.namespace)
5051
+ ).on(
5052
+ "change.phanterpwa_gallery_input_{0}".format(self.namespace),
5053
+ lambda: inputChange(this, self.config)
5054
+ )
5055
+
5056
+
4981
5057
  def _afterRead(self):
4982
- if self.config['current_image'] is not None and self.config['current_image'] is not js_undefined:
4983
- self.simpleView(self.config['current_image'])
5058
+ if self.config['is_image']:
5059
+ if self.config['current_image'] is not None and self.config['current_image'] is not js_undefined:
5060
+ self.simpleView(self.config['current_image'])
5061
+ else:
5062
+ jQuery(
5063
+ "#phanterpwa-gallery-upload-image-button-{0}".format(self.namespace)
5064
+ ).on(
5065
+ "click",
5066
+ lambda: self.getNewImage()
5067
+ )
4984
5068
  else:
4985
5069
  jQuery(
4986
- "#phanterpwa-gallery-upload-image-button-{0}".format(self.namespace)
5070
+ "#phanterpwa-gallery-upload-file-button-{0}".format(self.namespace)
4987
5071
  ).on(
4988
5072
  "click",
4989
- lambda: self.getNewImage()
5073
+ lambda: self.getNewFile()
4990
5074
  )
4991
5075
 
4992
5076
  def addInputPanel(self):
@@ -4996,105 +5080,214 @@ class GalleryInput():
4996
5080
  x_name = self.config.get('name', None)
4997
5081
  if x_name is not None:
4998
5082
  name = "-{0}".format(str(x_name))
4999
- if self.config['cutter']:
5083
+ if self.config['is_image']:
5084
+ if self.config['cutter']:
5000
5085
 
5001
- cutter_vars = [
5002
- INPUT(
5003
- _id='phanterpwa-gallery-input-cutterSizeX{0}'.format(self.namespace),
5004
- _name='phanterpwa-gallery-input-cutterSizeX{0}'.format(name),
5005
- _value="",
5006
- _type="text"
5007
- ),
5008
- INPUT(
5009
- _id='phanterpwa-gallery-input-cutterSizeY{0}'.format(self.namespace),
5010
- _name='phanterpwa-gallery-input-cutterSizeY{0}'.format(name),
5011
- _value="",
5012
- _type="text"
5086
+ cutter_vars = [
5087
+ INPUT(
5088
+ _id='phanterpwa-gallery-input-cutterSizeX{0}'.format(self.namespace),
5089
+ _name='phanterpwa-gallery-input-cutterSizeX{0}'.format(name),
5090
+ _value="",
5091
+ _type="text"
5092
+ ),
5093
+ INPUT(
5094
+ _id='phanterpwa-gallery-input-cutterSizeY{0}'.format(self.namespace),
5095
+ _name='phanterpwa-gallery-input-cutterSizeY{0}'.format(name),
5096
+ _value="",
5097
+ _type="text"
5098
+ ),
5099
+ INPUT(
5100
+ _id='phanterpwa-gallery-input-positionX{0}'.format(self.namespace),
5101
+ _name='phanterpwa-gallery-input-positionX{0}'.format(name),
5102
+ _value="",
5103
+ _type="text"
5104
+ ),
5105
+ INPUT(
5106
+ _id='phanterpwa-gallery-input-positionY{0}'.format(self.namespace),
5107
+ _name='phanterpwa-gallery-input-positionY{0}'.format(name),
5108
+ _value="",
5109
+ _type="text"
5110
+ ),
5111
+ INPUT(
5112
+ _id='phanterpwa-gallery-input-newSizeX{0}'.format(self.namespace),
5113
+ _name='phanterpwa-gallery-input-newSizeX{0}'.format(name),
5114
+ _value="",
5115
+ _type="text"
5116
+ ),
5117
+ INPUT(
5118
+ _id='phanterpwa-gallery-input-newSizeY{0}'.format(self.namespace),
5119
+ _name='phanterpwa-gallery-input-newSizeY{0}'.format(name),
5120
+ _value="",
5121
+ _type="text"
5122
+ ),
5123
+ INPUT(
5124
+ _id='phanterpwa-gallery-input-rotation{0}'.format(self.namespace),
5125
+ _name='phanterpwa-gallery-input-rotation{0}'.format(name),
5126
+ _value="",
5127
+ _type="text"
5128
+ )
5129
+ ]
5130
+ other_inputs = DIV(
5131
+ *cutter_vars,
5132
+ _class="phanterpwa-gallery-inputs-container-{0}".format(self.namespace),
5133
+ _style="display: none"
5134
+ )
5135
+ input_gallery = DIV(
5136
+ DIV(
5137
+ DIV(
5138
+ XML(self.config['button-upload']),
5139
+ _id="phanterpwa-gallery-upload-image-button-{0}".format(self.namespace),
5140
+ _class="phanterpwa-gallery-upload-image-button link",
5141
+ _phanterpwa_input="phanterpwa-gallery-input-file-{0}".format(self.namespace)
5142
+ ),
5143
+ _id="phanterpwa-gallery-upload-image-default-{0}".format(self.namespace),
5144
+ _class="phanterpwa-gallery-upload-image-default"
5013
5145
  ),
5014
5146
  INPUT(
5015
- _id='phanterpwa-gallery-input-positionX{0}'.format(self.namespace),
5016
- _name='phanterpwa-gallery-input-positionX{0}'.format(name),
5017
- _value="",
5018
- _type="text"
5147
+ _accept=self.config["accept_types"],
5148
+ _class="phanterpwa-gallery-upload-input-file",
5149
+ _type="file",
5150
+ _id="phanterpwa-gallery-input-file-{0}".format(self.namespace),
5151
+ _name="phanterpwa-gallery-file-input{0}".format(name),
5019
5152
  ),
5020
- INPUT(
5021
- _id='phanterpwa-gallery-input-positionY{0}'.format(self.namespace),
5022
- _name='phanterpwa-gallery-input-positionY{0}'.format(name),
5023
- _value="",
5024
- _type="text"
5153
+ _id="phanterpwa-gallery-input-container-{0}".format(self.namespace),
5154
+ _class="phanterpwa-gallery-input-container"
5155
+ )
5156
+ wrapper_gallery = DIV(
5157
+ input_gallery,
5158
+ other_inputs,
5159
+ _id="phanterpwa-gallery-wrapper-{0}".format(self.namespace),
5160
+ _class="phanterpwa-gallery-wrapper"
5161
+ )
5162
+
5163
+ html = DIV(
5164
+ DIV(
5165
+ DIV(
5166
+ DIV(
5167
+ wrapper_gallery,
5168
+ _class="phanterpwa-centralizer-center"
5169
+ ),
5170
+ _class="phanterpwa-centralizer-horizontal"
5171
+ ),
5172
+ _class="phanterpwa-centralizer-vertical"
5025
5173
  ),
5026
- INPUT(
5027
- _id='phanterpwa-gallery-input-newSizeX{0}'.format(self.namespace),
5028
- _name='phanterpwa-gallery-input-newSizeX{0}'.format(name),
5029
- _value="",
5030
- _type="text"
5174
+ _class="phanterpwa-centralizer-wrapper",
5175
+ _style="width: {0}px; height: {1}px;".format(self.config['view-width'], self.config['view-height'])
5176
+ )
5177
+ jQuery(self.target_selector).html(
5178
+ html.xml()
5179
+ ).promise().then(
5180
+ lambda: self._afterRead()
5181
+ )
5182
+ else:
5183
+ input_gallery = DIV(
5184
+ DIV(
5185
+ DIV(
5186
+ XML(self.config['button-upload']),
5187
+ _id="phanterpwa-gallery-upload-file-button-{0}".format(self.namespace),
5188
+ _class="phanterpwa-gallery-upload-file-button link",
5189
+ _phanterpwa_input="phanterpwa-gallery-input-file-{0}".format(self.namespace)
5190
+ ),
5191
+ _id="phanterpwa-gallery-upload-file-default-{0}".format(self.namespace),
5192
+ _class="phanterpwa-gallery-upload-file-default"
5031
5193
  ),
5032
5194
  INPUT(
5033
- _id='phanterpwa-gallery-input-newSizeY{0}'.format(self.namespace),
5034
- _name='phanterpwa-gallery-input-newSizeY{0}'.format(name),
5035
- _value="",
5036
- _type="text"
5195
+ _accept=self.config["accept_types"],
5196
+ _class="phanterpwa-gallery-upload-input-file",
5197
+ _type="file",
5198
+ _id="phanterpwa-gallery-input-file-{0}".format(self.namespace),
5199
+ _name="phanterpwa-gallery-file-input{0}".format(name),
5037
5200
  ),
5038
- INPUT(
5039
- _id='phanterpwa-gallery-input-rotation{0}'.format(self.namespace),
5040
- _name='phanterpwa-gallery-input-rotation{0}'.format(name),
5041
- _value="",
5042
- _type="text"
5043
- )
5044
- ]
5045
- other_inputs = DIV(
5046
- *cutter_vars,
5047
- _class="phanterpwa-gallery-inputs-container-{0}".format(self.namespace),
5048
- _style="display: none"
5201
+ _id="phanterpwa-gallery-input-container-{0}".format(self.namespace),
5202
+ _class="phanterpwa-gallery-input-container"
5049
5203
  )
5050
- input_gallery = DIV(
5051
- DIV(
5204
+ wrapper_gallery = DIV(
5205
+ input_gallery,
5206
+ other_inputs,
5207
+ _id="phanterpwa-gallery-wrapper-{0}".format(self.namespace),
5208
+ _class="phanterpwa-gallery-wrapper"
5209
+ )
5210
+
5211
+ html = DIV(
5052
5212
  DIV(
5053
- XML(self.config['button-upload']),
5054
- _id="phanterpwa-gallery-upload-image-button-{0}".format(self.namespace),
5055
- _class="phanterpwa-gallery-upload-image-button link",
5056
- _phanterpwa_input="phanterpwa-gallery-input-file-{0}".format(self.namespace)
5213
+ DIV(
5214
+ DIV(
5215
+ wrapper_gallery,
5216
+ _class="phanterpwa-centralizer-center"
5217
+ ),
5218
+ _class="phanterpwa-centralizer-horizontal"
5219
+ ),
5220
+ _class="phanterpwa-centralizer-vertical"
5057
5221
  ),
5058
- _id="phanterpwa-gallery-upload-image-default-{0}".format(self.namespace),
5059
- _class="phanterpwa-gallery-upload-image-default"
5060
- ),
5061
- INPUT(
5062
- _accept=self.config["accept_types"],
5063
- _class="phanterpwa-gallery-upload-input-file",
5064
- _type="file",
5065
- _id="phanterpwa-gallery-input-file-{0}".format(self.namespace),
5066
- _name="phanterpwa-gallery-file-input{0}".format(name),
5067
- ),
5068
- _id="phanterpwa-gallery-input-container-{0}".format(self.namespace),
5069
- _class="phanterpwa-gallery-input-container"
5070
- )
5071
- wrapper_gallery = DIV(
5072
- input_gallery,
5073
- other_inputs,
5074
- _id="phanterpwa-gallery-wrapper-{0}".format(self.namespace),
5075
- _class="phanterpwa-gallery-wrapper"
5076
- )
5222
+ _class="phanterpwa-centralizer-wrapper",
5223
+ _style="width: {0}px; height: {1}px;".format(self.config['view-width'], self.config['view-height'])
5224
+ )
5225
+ jQuery(self.target_selector).html(
5226
+ html.xml()
5227
+ ).promise().then(
5228
+ lambda: self._afterRead()
5229
+ )
5077
5230
 
5078
- html = DIV(
5231
+ def fileChoiced(self):
5232
+ namespace = self.config['namespace']
5233
+ img_name = self.config["img_name"]
5234
+ xml_icons_view = ""
5235
+ if not self._data_view:
5236
+ xml_icons_view = DIV(
5237
+ DIV(
5238
+ I(_class="fas fa-sync"),
5239
+ _id="phanterpwa-gallery-upload-file-simple-view-button-reload-{0}".format(namespace),
5240
+ _class="phanterpwa-gallery-upload-file-simple-view-button {0}".format(
5241
+ "phanterpwa-gallery-upload-file-simple-view-button-reload"
5242
+ )
5243
+ ),
5244
+ DIV(
5245
+ I(_class="fas fa-trash-alt"),
5246
+ _id="phanterpwa-gallery-upload-file-simple-view-button-delete-{0}".format(namespace),
5247
+ _class="phanterpwa-gallery-upload-file-simple-view-button {0}".format(
5248
+ "phanterpwa-gallery-upload-file-simple-view-button-delete"
5249
+ )
5250
+ ),
5251
+ _class="phanterpwa-gallery-upload-file-simple-view-buttons"
5252
+ )
5253
+ html_simple_view = DIV(
5079
5254
  DIV(
5080
5255
  DIV(
5081
- DIV(
5082
- wrapper_gallery,
5083
- _class="phanterpwa-centralizer-center"
5084
- ),
5085
- _class="phanterpwa-centralizer-horizontal"
5256
+ I(_class="fas fa-file"),
5257
+ _class="file-icon"
5086
5258
  ),
5087
- _class="phanterpwa-centralizer-vertical"
5259
+ DIV(img_name, _class="file-name"),
5260
+ _class="phanterpwa-gallery-upload-file-icon_and_name"
5088
5261
  ),
5089
- _class="phanterpwa-centralizer-wrapper",
5090
- _style="width: {0}px; height: {1}px;".format(self.config['view-width'], self.config['view-height'])
5262
+ xml_icons_view,
5263
+ _id="phanterpwa-gallery-upload-file-simple-view-{0}".format(namespace),
5264
+ _class="phanterpwa-gallery-upload-file-simple-view",
5265
+ _style="width: 150px; height: 150px; overflow: hidden;"
5091
5266
  )
5092
- jQuery(self.target_selector).html(
5093
- html.xml()
5094
- ).promise().then(
5095
- lambda: self._afterRead()
5267
+
5268
+ def activeButtonsView():
5269
+ jQuery(
5270
+ "#phanterpwa-gallery-upload-file-simple-view-button-reload-{0}".format(namespace)
5271
+ ).off(
5272
+ "click.button-reload-view"
5273
+ ).on(
5274
+ "click.button-reload-view",
5275
+ lambda: self.getNewFile()
5276
+ )
5277
+ jQuery(
5278
+ "#phanterpwa-gallery-upload-file-simple-view-button-delete-{0}".format(namespace)
5279
+ ).off(
5280
+ "click.button-reload-view"
5281
+ ).on(
5282
+ "click.button-reload-view",
5283
+ lambda: self.resetInputPanel()
5284
+ )
5285
+
5286
+ jQuery("#phanterpwa-gallery-upload-file-default-{0}".format(namespace)).html(html_simple_view.xml()).promise().then(
5287
+ lambda: activeButtonsView()
5096
5288
  )
5097
5289
 
5290
+
5098
5291
  def simpleView(self, url):
5099
5292
  namespace = self.config['namespace']
5100
5293
  width = self.config["width"]
@@ -246,3 +246,81 @@ class PhanterpwaGalleryImage():
246
246
  ))
247
247
  if os.path.exists(file):
248
248
  return file
249
+
250
+
251
+ class PhanterpwaGalleryFile():
252
+
253
+ def __init__(self, sub_folder, db, projectConfig, id_file=0, appname="api"):
254
+ self.db = db
255
+ self.upload_folder = os.path.normpath(
256
+ os.path.join(projectConfig["PROJECT"]["path"], "backapps", appname, "uploads")
257
+ )
258
+ self.projectConfig = projectConfig
259
+ self.sub_folder = sub_folder
260
+ self.id_file = id_file
261
+
262
+ def alias_name(self, filename, id_file):
263
+ ext = ""
264
+ f_name = filename
265
+ if "." in filename:
266
+ ext = filename.split(".")[-1]
267
+ f_name = "{0}.{1}".format(id_file, ext)
268
+ return f_name
269
+
270
+ def set_file(self, filename, file, content_type):
271
+ db = self.db
272
+ target_folder = os.path.join(self.upload_folder, self.sub_folder)
273
+ os.makedirs(target_folder, exist_ok=True)
274
+ rel_folder = os.path.join(self.sub_folder)
275
+ if self.id_file:
276
+ s_file = self.db(
277
+ (self.db.phanterpwagallery.id == self.id_file)).select().first()
278
+ if s_file:
279
+ id_new_file = s_file.update_record(
280
+ folder=rel_folder,
281
+ filename=filename,
282
+ content_type=content_type
283
+ )
284
+
285
+ else:
286
+ id_new_file = self.db.phanterpwagallery.insert(
287
+ folder=rel_folder,
288
+ filename=filename,
289
+ content_type=content_type
290
+ )
291
+
292
+ else:
293
+ id_new_file = self.db.phanterpwagallery.insert(
294
+ folder=rel_folder,
295
+ filename=filename,
296
+ content_type=content_type
297
+ )
298
+
299
+ self.db.commit()
300
+
301
+ if id_new_file:
302
+ self.id_file = id_new_file.id
303
+ alias_name = self.alias_name(filename, self.id_file)
304
+ q_img = db(db.phanterpwagallery.id == self.id_file).select().first()
305
+ q_img.update_record(
306
+ alias_name=alias_name
307
+ )
308
+ self.db.commit()
309
+ with open(
310
+ os.path.join(target_folder, alias_name),
311
+ 'wb') as new_file:
312
+ new_file.write(file)
313
+ return self.id_file
314
+
315
+ @property
316
+ def path_file(self):
317
+ s_file = self.db(
318
+ (self.db.phanterpwagallery.id == self.id_file)).select().last()
319
+ if s_file:
320
+ file = os.path.normpath(os.path.join(
321
+ self.upload_folder,
322
+ s_file.folder,
323
+ s_file.alias_name
324
+ ))
325
+ if os.path.exists(file):
326
+ return file
phanterpwa/tools.py CHANGED
@@ -677,6 +677,19 @@ def text_normalize(text: str, upper: bool = True) -> str:
677
677
  return normalize('NFKD', text).encode('ascii', 'ignore').decode('ascii')
678
678
 
679
679
 
680
+ def filter_for_a_valid_filename(value):
681
+ texto = str(value)
682
+ mini = "ÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛÃÕÄËÏÖÜÇABCDEFGHIJKLMNOPQRSTUVWXYZ áéíóúàèìòùâêîôûãõäëïöüabçcdefghijlmnopqrstuvxzwyk0123456789ªº°[{()}]"
683
+ novo_texto = ""
684
+ for x in texto:
685
+ if x in mini:
686
+ novo_texto = "".join([novo_texto, x])
687
+ else:
688
+ novo_texto = "".join([novo_texto, " "])
689
+ texto = one_space(novo_texto)
690
+ return texto
691
+
692
+
680
693
  def string_escape(value):
681
694
  r"""Escapes the <,>, ", 'and & characters of a string, when adding an interactable object such as a list,
682
695
  a dictionary, tuples and a set it cycles through the values in search of strings recursively, remembering
@@ -1199,4 +1212,4 @@ class WatchingFiles():
1199
1212
  else:
1200
1213
  del files_delete[ff]
1201
1214
  del self._files[ff]
1202
- time.sleep(1)
1215
+ time.sleep(1)
@@ -7,7 +7,7 @@
7
7
  .phanterpwa-gallery-upload-input-file
8
8
  display: none
9
9
 
10
- .phanterpwa-gallery-upload-image-simple-view-buttons
10
+ .phanterpwa-gallery-upload-image-simple-view-buttons, .phanterpwa-gallery-upload-file-simple-view-buttons
11
11
  padding: 2px 4px
12
12
  background-color: rgba(0,0,0,0.7)
13
13
  position: absolute
@@ -25,4 +25,19 @@
25
25
  &:hover
26
26
  color: $attention
27
27
  .phanterpwa-gallery-wrapper
28
- position: relative
28
+ position: relative
29
+
30
+ .phanterpwa-gallery-upload-file-button
31
+ color: $components
32
+ text-align: center
33
+ i
34
+ font-size: 3rem
35
+ cursor: pointer
36
+ &:hover
37
+ color: $attention
38
+
39
+ .phanterpwa-gallery-upload-file-simple-view
40
+ .phanterpwa-gallery-upload-file-icon_and_name
41
+ .file-icon
42
+ font-size: 100px
43
+
@@ -33,9 +33,10 @@
33
33
  opacity: 1
34
34
  transition: opacity 0.5s
35
35
 
36
- .phanterpwa-gallery-upload-image-button .phanterwebsvg.upload-cloud
37
- font-size: 50px
38
- color: red
36
+ .phanterpwa-gallery-upload-image-button, .phanterpwa-gallery-upload-file-button
37
+ .phanterwebsvg.upload-cloud
38
+ font-size: 50px
39
+ color: red
39
40
 
40
41
  .phanterpwa-gallery-panel-cutter-container
41
42
  display: none
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phanterpwa
3
- Version: 13.14.4
3
+ Version: 13.14.7
4
4
  Summary: Tools for the phanterpwadeveloper framework
5
5
  Home-page: https://github.com/PhanterJR/phanterpwa
6
6
  Author: PhanterJR
@@ -1,4 +1,4 @@
1
- phanterpwa/__init__.py,sha256=Mrand-gO1ww2akeAYsghkLRg2XwohP_fBXUC6jR6QXo,397
1
+ phanterpwa/__init__.py,sha256=AhbZpKs-67BOiN1RrRBhCWPOS8DxhWA-9CBNcjsGtcI,397
2
2
  phanterpwa/__main__.py,sha256=1vSHtv6-sgAgpZiklf9bwarXX1b-fmKx1rjwJw4h78o,4017
3
3
  phanterpwa/compiler.py,sha256=Je3qtVO_cZ69_PPWcXKyBgnRfQ-Ev-zkZ3UTN-ddOTQ,47478
4
4
  phanterpwa/configer.py,sha256=O0IO5rf-hwFNdBjcz94OF-fqXKTWbqPElTsfS5V2beY,26327
@@ -7,11 +7,11 @@ phanterpwa/mail.py,sha256=YrsiIQY_SpqySIc7mi6MfyY881DIsoYAJ5dPAz8vorE,5741
7
7
  phanterpwa/reversexml.py,sha256=YJeI8VuzEPw0D2z0Cz-HLt2n27WyJawZh6HRNZX5Ujg,10764
8
8
  phanterpwa/server.py,sha256=jXqnSfk4fLEgXKaRqiZ3fimcZNbvThKVSbTbJJZYb0E,12247
9
9
  phanterpwa/sms.py,sha256=XUULyDSk5gPjBqupchIcaGv-C6kX66XxrXpmzfnSp_A,1313
10
- phanterpwa/tools.py,sha256=H1VfJe9c3qaeR3KYpKz0KHHx6j7fRaa_kBaZsCiawxs,45683
10
+ phanterpwa/tools.py,sha256=SKwqx_suix-b1DP72a7z98jlnSWDmtGNWgCQq_ogB1I,46173
11
11
  phanterpwa/xmlconstructor.py,sha256=DMtc9BXI2NMGGmLszZXh2A63Iv0D1qgoWtn0aKyrmoo,162695
12
12
  phanterpwa/backend/__init__.py,sha256=zB8rm2I9O3f448YsuaupgBlAoqZAiVM5vEoWnOOGvdw,68
13
13
  phanterpwa/backend/dataforms.py,sha256=HwR8D-4vBNXdN5MSpZmjelo-Az92lVvOTIzpbHnPpsg,64543
14
- phanterpwa/backend/decorators.py,sha256=WPu_tsHVeZ6qNsmVLZ2GanhJgsaKfooql_v2yB94exM,55451
14
+ phanterpwa/backend/decorators.py,sha256=cNgnPDGj1n47gKxQjcpN7z4bbzyj6lTmqXEGTUDt_og,55413
15
15
  phanterpwa/backend/security.py,sha256=USPky7nqTKASAN60yYs7-NnoR82LMZlf9aGlfz1QbXM,1300
16
16
  phanterpwa/backend/pydal/__init__.py,sha256=lpPDHcS9anJ5ceRSW9fBVuAgKK5qtjSoMsVjp3_nCdw,55
17
17
  phanterpwa/backend/pydal/auth.py,sha256=g_HToe-Lewtz4MmD9_KBtFmDl1SfBel0Pp_NDX36Y44,8558
@@ -21,13 +21,13 @@ phanterpwa/backend/pydal/extra_validations.py,sha256=1FlOZhUuYg4aybL4EwSzH3zWUXb
21
21
  phanterpwa/backend/pydal/gallery.py,sha256=nETfQ2Dv-0N94Ypq14uGiDKeGlWgxDHLjY4s1zFrnWs,870
22
22
  phanterpwa/backend/pydal/internal_messages.py,sha256=DYDNWpjrvAM0Nn4m5fGkJXJsMVQjwuJgcMaRzOEzmE4,1379
23
23
  phanterpwa/backend/request_handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- phanterpwa/backend/request_handlers/admin.py,sha256=-wccEEV-JaVWPFLnX4WQ0TOjiCHRnVmPixfc0feYImk,59625
25
- phanterpwa/backend/request_handlers/auth.py,sha256=hdbhdtyjVG_lqm__X_0fG9zTOmpCF3AjCSwMIRbLlgw,167385
24
+ phanterpwa/backend/request_handlers/admin.py,sha256=fRiGgc3S-Jo0GSHmpamEunMXT1M8PBUYAb3iCzmVuJw,59688
25
+ phanterpwa/backend/request_handlers/auth.py,sha256=0CnHMEtxDPFtMOMyeYh7CP-21_wky8of3SOyeF6u5Ms,167511
26
26
  phanterpwa/backend/request_handlers/cas.py,sha256=x041v85dklkP9dPmDqZVMHZaBXcTwXU9LWnRDk42pl0,24299
27
27
  phanterpwa/backend/request_handlers/credentials.py,sha256=eBa8UAmInI-k7PKXh65XbWe58hCkxrALTqdyGt3GqxI,47702
28
28
  phanterpwa/backend/request_handlers/errors.py,sha256=_WG-K1Igh_IVn6t1pEzP7QgpBq_2pP2sGz_jbj3Cth4,3775
29
29
  phanterpwa/backend/request_handlers/i18n_server.py,sha256=dMx3NvmaaBWese5U4Jw2kzKIki3-HwXYmgVOqK04R3o,2490
30
- phanterpwa/backend/request_handlers/internal_messages.py,sha256=02Qnraq8grVWFSGpPtuyFSqs1qMkOGWXngdtglj5rpM,15986
30
+ phanterpwa/backend/request_handlers/internal_messages.py,sha256=tuKiTZ41qy_64cFaUujBEjajLZMSSkXs2XiE-WQF9Ls,15952
31
31
  phanterpwa/backend/request_handlers/oauth.py,sha256=vofvvRTcea5LusXzZ0FptKM6gOgYOaqPPDG2OYK4i8k,44555
32
32
  phanterpwa/backend/request_handlers/websocket.py,sha256=KgS9RCsMlTmvFWG8kaLrsL3sv2O3rS4yn63FbNtr0tg,5716
33
33
  phanterpwa/backend/request_handlers/welcome.py,sha256=w_h7UccR9g1-Dfy7AVqc74FLQzrgBjbY5rDhgAMUHno,723
@@ -68,7 +68,7 @@ phanterpwa/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
68
68
  phanterpwa/components/inputs.py,sha256=YT9a6IPZiZTj2jalmqrfl9Fy_OSF4I25dO2OMcigh1I,14007
69
69
  phanterpwa/components/left_bar.py,sha256=vZ2ceKn4U586ZYrJx3tfWg4m9ODIu5mD7JWyVbw7uGY,6111
70
70
  phanterpwa/components/materialize.py,sha256=kaNF5seiY2rAm7aUt4uwYE9Guu7s5qdtf7qflGOwuq0,25523
71
- phanterpwa/components/phanterpwagallery.py,sha256=RkWhV7jsFyA9nJ0IpnrL1iZXX-OOBoiIJMEPWyav7oA,19016
71
+ phanterpwa/components/phanterpwagallery.py,sha256=NdmuAZFOfeDBebB6_HDjz7akr6XiY00V00mF3hoKeVI,18987
72
72
  phanterpwa/components/preloaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  phanterpwa/components/preloaders/android.py,sha256=8vBU-ymVjbI5pcwBdzUa8Yuy9WlgIJlaeeTdKMnftIE,3584
74
74
  phanterpwa/components/preloaders/android.sass,sha256=JV-bJ0F-909NdP-RS1ZDUUpbLRuyWn-M7Dl6gN44qVI,7879
@@ -109,11 +109,11 @@ phanterpwa/frontend/components/modal.py,sha256=q4v2z3HUS58lJ49E6ZWCEkSRVXy7kMiy5
109
109
  phanterpwa/frontend/components/pagination.py,sha256=IJIyReYbKRj4OTVsZbNiCMfSOIq7qSLpFTF9qQdPbFM,791
110
110
  phanterpwa/frontend/components/snippets.py,sha256=fm-QPIJ_Mv8fSHsS3UK8Bq8Iw_ziaECwEr-VjcaiPQw,4060
111
111
  phanterpwa/frontend/components/top_slide.py,sha256=ReB0z63I9HjT8iq6ZfNB56KoZLzBxdfcFCIw7QjRQvU,3175
112
- phanterpwa/frontend/components/widgets.py,sha256=WvtRv8DecXPAPWmF19NKwKNvG3Wv2SnoOC1WaWVGTrk,254275
112
+ phanterpwa/frontend/components/widgets.py,sha256=eRIqJpeoCjZgf25J_kZvf0_fufH6hYLm38RDuzkJQBg,262815
113
113
  phanterpwa/frontend/plugins/client.py,sha256=0x1HmGq6-WAap9RGl2szQj1GXClyGVtnznuYMwpUdb8,27481
114
114
  phanterpwa/gallery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
115
  phanterpwa/gallery/cutter.py,sha256=0-VnFa3aQ5XgNmA4P3BsL-_04IwkjrgHImKIrL3qViM,7789
116
- phanterpwa/gallery/integrationDAL.py,sha256=iOBxySQB_a6P5mhIV5Uie2xdnIzCZlq0iGHq_D3mN5k,9088
116
+ phanterpwa/gallery/integrationDAL.py,sha256=D4edoJSAqQiRQ5nkZh__JlIKwtJy3i6_UV-KRoDI9Vw,11679
117
117
  phanterpwa/i18n/__init__.py,sha256=Xetm9mg4Kll_YiRw8CPc_FhP_B-yWp6q4aQMj-hsloE,8670
118
118
  phanterpwa/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
119
119
  phanterpwa/interface/admin_tk.py,sha256=Wlpqx24e-GFXmYvP55gl_v2PXOU1zoEkP6Fks8tb2Jw,7015
@@ -409,8 +409,8 @@ phanterpwa/usual_sass/components/forms.sass,sha256=6VyYWA470Dgc8Nn0VKvbcK-tz4E7K
409
409
  phanterpwa/usual_sass/components/messages.sass,sha256=zmP_ZlhRWSvWq9mv5EAR3_FkhQmNLxQhnYgGDiN4yvk,1888
410
410
  phanterpwa/usual_sass/components/modal.sass,sha256=tW1WRHt4LHIruzYCqowag89WLBAeKNxFCG5rQ_VfooI,3190
411
411
  phanterpwa/usual_sass/components/modal_login.sass,sha256=I25IkPq9NxM2qGCgkkZFWlgQcYBpCTsJUuPTHKzNI3o,1694
412
- phanterpwa/usual_sass/components/phanterpwa_gallery.sass,sha256=aO4WpI2lp7wf-oxkzjWT9uHuvssZfAgB_Sp-TPiBUMQ,649
413
- phanterpwa/usual_sass/components/phanterpwa_gallery_cutter.sass,sha256=El6H79FrUWk3rEAmJxTYHamcIkIoDWeYWTi4Mh8MLJ0,4103
412
+ phanterpwa/usual_sass/components/phanterpwa_gallery.sass,sha256=gKBMk87yJHEMAIQMs2iaGtf4753nlJlfdNhXsb7wk0A,1051
413
+ phanterpwa/usual_sass/components/phanterpwa_gallery_cutter.sass,sha256=bl7WBmAMsUzmCQvSTSBWURjcmzpUZ0Z9AVxim7P7WIQ,4149
414
414
  phanterpwa/usual_sass/components/phanterpwa_panel_control.sass,sha256=Dz5nAVCSBn4S6tajRtYpAe6aOt4p_Ey5yB5imL3bcYA,1450
415
415
  phanterpwa/usual_sass/components/progressbar.sass,sha256=VXhfcoc5dT5ESPb71nAg7h_CzMYHGU-DQDmlt-jOelM,2959
416
416
  phanterpwa/usual_sass/components/pseudomodal.sass,sha256=Z6uYVGhdbE5sIvMwLmEEPRIUZsFklkXPFLqwQ38bYwA,660
@@ -435,10 +435,10 @@ phanterpwa/usual_sass/preloaders/indefined_text.sass,sha256=z4JuUtBrzoqH3HuNFXvN
435
435
  phanterpwa/usual_sass/preloaders/run_points.sass,sha256=EYl93ljfgAc-ZLJ0VScrCoIlHP7Nr6NLdxj1zk2wm_E,3367
436
436
  phanterpwa/usual_sass/preloaders/square.sass,sha256=TOsh9muP4zkYLUJcw4i1LeRs60NrtgRWBk_1oMt2_58,1348
437
437
  phanterpwa/usual_sass/preloaders/squares.sass,sha256=kH1I89qEfmbvYxCtKFVNcxP5bWIjnqbheXVnyGF0VNo,3862
438
- phanterpwa-13.14.4.dist-info/LICENSE,sha256=lGEW1PRSZOkug2-d0IJgryCjqt6zhxN5x9pFgy3lx2E,1087
439
- phanterpwa-13.14.4.dist-info/METADATA,sha256=Iu58l2FRNRhQUcvIr5BBhP3a1X1sgXX4oZf_c7MvuMI,1939
440
- phanterpwa-13.14.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
441
- phanterpwa-13.14.4.dist-info/dependency_links.txt,sha256=Pslekmz-4l1SpBO0x2aYkYZPCScmbrB9HUq1YvXYUzM,40
442
- phanterpwa-13.14.4.dist-info/entry_points.txt,sha256=siJH2lFXIdsUBDRgcXV4blOb2_iku1vcbqxJ-trIQrw,56
443
- phanterpwa-13.14.4.dist-info/top_level.txt,sha256=nF1WJ8AByxBv3bLKp3xySR2l2Twrj5n5n7C404lULSk,5319
444
- phanterpwa-13.14.4.dist-info/RECORD,,
438
+ phanterpwa-13.14.7.dist-info/LICENSE,sha256=lGEW1PRSZOkug2-d0IJgryCjqt6zhxN5x9pFgy3lx2E,1087
439
+ phanterpwa-13.14.7.dist-info/METADATA,sha256=z1It8q59OvAf3fB4WpH_JbZQabq2mvQnuGPqrQ4J1Tw,1939
440
+ phanterpwa-13.14.7.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
441
+ phanterpwa-13.14.7.dist-info/dependency_links.txt,sha256=Pslekmz-4l1SpBO0x2aYkYZPCScmbrB9HUq1YvXYUzM,40
442
+ phanterpwa-13.14.7.dist-info/entry_points.txt,sha256=siJH2lFXIdsUBDRgcXV4blOb2_iku1vcbqxJ-trIQrw,56
443
+ phanterpwa-13.14.7.dist-info/top_level.txt,sha256=nF1WJ8AByxBv3bLKp3xySR2l2Twrj5n5n7C404lULSk,5319
444
+ phanterpwa-13.14.7.dist-info/RECORD,,