fix_admin_portfolio.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import re
  2. path = r"d:\radionica3d\src\pages\Admin.vue"
  3. with open(path, 'r', encoding='utf-8') as f:
  4. content = f.read()
  5. # Define the pattern to find the portfolio section
  6. # We'll use a broad pattern to find the div with the portfolio tab
  7. pattern = re.compile(r'(<!-- PORTFOLIO -->\s+<div v-else-if="activeTab === \'portfolio\'".*?</div>\s+</div>)', re.DOTALL)
  8. portfolio_replacement = """<!-- PORTFOLIO -->
  9. <div v-else-if="activeTab === 'portfolio'" class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
  10. <div v-for="pi in portfolioItems" :key="pi.id" class="group relative aspect-square bg-card/40 border border-border/50 rounded-2xl overflow-hidden hover:border-primary/30 transition-all">
  11. <img :src="`http://localhost:8000/${pi.file_path}`" class="w-full h-full object-cover" />
  12. <!-- Status Overlay -->
  13. <div class="absolute top-2 left-2 flex gap-1">
  14. <span :class="`px-2 py-0.5 rounded-full text-[8px] font-bold uppercase ${pi.is_public ? 'bg-emerald-500 text-white shadow-glow' : 'bg-black/40 text-white/40'}`">
  15. {{ pi.is_public ? 'Public' : 'Private' }}
  16. </span>
  17. <span v-if="!pi.allow_portfolio" class="px-2 py-0.5 rounded-full text-[8px] font-bold uppercase bg-rose-500 text-white">
  18. No Consent
  19. </span>
  20. </div>
  21. <div class="absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center justify-center p-4 gap-3">
  22. <div class="flex items-center gap-2">
  23. <button @click="handleTogglePhotoPublic(pi.id, pi.is_public, pi.allow_portfolio)"
  24. :class="`p-2 rounded-xl transition-all ${pi.is_public ? 'bg-emerald-500 text-white' : 'bg-white/10 text-white hover:bg-white/20'}`"
  25. :title="pi.is_public ? t('admin.actions.makePrivate') : t('admin.actions.makePublic')">
  26. <Eye v-if="pi.is_public" class="w-4 h-4" /><EyeOff v-else class="w-4 h-4" />
  27. </button>
  28. <a :href="`http://localhost:8000/${pi.file_path}`" target="_blank" class="p-2 bg-white/10 text-white hover:bg-white/20 rounded-xl transition-all">
  29. <ExternalLink class="w-4 h-4" />
  30. </a>
  31. <button @click="handleDeletePhoto(pi.id)" class="p-2 bg-rose-500/20 text-rose-500 hover:bg-rose-500 hover:text-white rounded-xl transition-all">
  32. <Trash2 class="w-4 h-4" />
  33. </button>
  34. </div>
  35. <p v-if="pi.material_name" class="text-[9px] font-bold text-primary uppercase mt-1">{{ pi.material_name }}</p>
  36. </div>
  37. </div>
  38. </div>"""
  39. new_content = pattern.sub(portfolio_replacement, content)
  40. with open(path, 'w', encoding='utf-8') as f:
  41. f.write(new_content)
  42. print("Replacement successful")