Py.Cafe

pyponcoroweline/

sk-barangay-connect-portal-0

SK Barangay Connect Portal

DocsPricing
  • app.py
  • busagak_cleanup.jpeg
  • cert.jpg
  • pamuo-awards-panel-interview.jpeg
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import streamlit as st
st.set_page_config(page_title="SK Youth Portal", layout="wide")
st.markdown("""
    <style>
    .main { background-color: #0e1117; color: white; }
    .stButton>button { border-radius: 20px; background-color: #00d4ff; color: black; font-weight: bold; }
    </style>
    """, unsafe_allow_html=True)
st.title("πŸš€ SK Barangay Connect")
st.subheader("Your interactive space for a better community.")
menu = st.sidebar.radio("Go to:", ["Activity Feed", "Evaluate Us", "Youth Ideas"])
if menu == "Activity Feed":
    col1, col2 = st.columns(2)
    with col1:
        st.image("pamuo-awards-panel-interview.jpeg", caption="Pamuo Awards Panel Interview")
        st.write("The SK Council participated in the PAMUO Awards Validation and Panel Interview, an inspiring milestone that celebrates dedication, service, and true leadership.")
    with col2:
        st.image("busagak_cleanup.jpeg", caption="Busagak Cleaup")
        st.write("Busagak Falls Annual Clean-up")
elif menu == "Evaluate Us":
    st.header("Post-Activity Feedback")
    event = st.selectbox("Which activity did you attend?", ["Basketball", "Seminar", "Cleanup"])
    rating = st.feedback("stars")
    comment = st.text_area("What's one thing we should change?")
    if st.button("Submit My Vote"):
        st.balloons()
        st.success("Thank you! Your voice matters.")
import pandas as pd
leaderboard_data = {
    "Name": ["Juan Dela Cruz", "Maria Clara", "Kiko Matsing", "Inday Sahog", "Dodong Tech"],
    "Points": [150, 125, 90, 85, 50],
    "Badges": ["πŸ… Gold", "πŸ₯ˆ Silver", "πŸ₯‰ Bronze", "🌱 Active", "πŸ†• Newcomer"]
}
df = pd.DataFrame(leaderboard_data)

st.title("πŸ† Youth Leadership Leaderboard")
st.write("Top contributors in our Barangay this month!")

# Creating "Podium" style display for the Top 3
col1, col2, col3 = st.columns(3)
with col2: # Rank 1 in the middle
    st.metric(label="1st Place", value=df.iloc[0]["Name"], delta=f"{df.iloc[0]['Points']} pts")
    st.caption("Barangay MVP πŸ‘‘")

with col1: # Rank 2 on the left
    st.metric(label="2nd Place", value=df.iloc[1]["Name"], delta=f"{df.iloc[1]['Points']} pts")

with col3: # Rank 3 on the right
    st.metric(label="3rd Place", value=df.iloc[2]["Name"], delta=f"{df.iloc[2]['Points']} pts")

st.divider()
st.subheader("Current Rankings")
st.dataframe(
    df, 
    column_config={
        "Points": st.column_config.ProgressColumn("Points Progress", min_value=0, max_value=200),
    },
    hide_index=True,
    use_container_width=True
)
from fpdf import FPDF
import base64

def create_certificate(user_name, activity_name, points):
    pdf = FPDF(orientation='L', unit='mm', format='A4') # Landscape orientation
    pdf.add_page()
    
    # 1. Add a Border
    pdf.set_line_width(2)
    pdf.rect(10, 10, 277, 190)
    
    # 2. Add Content
    pdf.set_font('Arial', 'B', 30)
    pdf.cell(0, 40, 'CERTIFICATE OF APPRECIATION', ln=True, align='C')
    
    pdf.set_font('Arial', '', 18)
    pdf.cell(0, 20, 'This is proudly presented to:', ln=True, align='C')
    
    pdf.set_font('Arial', 'B', 35)
    pdf.cell(0, 30, user_name, ln=True, align='C')
    
    pdf.set_font('Arial', '', 18)
    pdf.write(10, f'For outstanding participation in "{activity_name}"\n')
    pdf.write(10, f'and earning {points} Leadership Points.')
    
    return pdf.output(dest='S').encode('latin-1')

st.title("πŸŽ“ SK Digital Certificate Portal")

name = st.text_input("Enter your Full Name:")
activity = st.selectbox("Select Activity:", ["Coastal Cleanup", "Basketball League", "Tech Seminar"])
points_earned = 50 # This would normally come from your leaderboard logic

if st.button("Generate My Certificate"):
    if name:
        pdf_bytes = create_certificate(name, activity, points_earned)
        st.balloons()
        st.download_button(
            label="⬇️ Download Certificate (PDF)",
            data=pdf_bytes,
            file_name=f"SK_Certificate_{name}.pdf",
            mime="application/pdf"
        )
    else:
        st.error("Please enter your name first!")
import pandas as pd
from fpdf import FPDF
st.set_page_config(page_title="SK Barangay Hub", page_icon="πŸš€", layout="wide")

# Custom CSS for a modern "Glassmorphism" look
st.markdown("""
    <style>
    .main { background: linear-gradient(135deg, #1e1e2f, #2d2d44); color: white; }
    div.stButton > button {
        background-color: #00f2fe; color: #1e1e2f; 
        border-radius: 10px; font-weight: bold; width: 100%;
    }
    </style>
    """, unsafe_allow_html=True)
def generate_pdf(name, activity):
    pdf = FPDF(orientation='L', unit='mm', format='A4')
    pdf.add_page()
    pdf.set_draw_color(0, 242, 254) # SK Blue Border
    pdf.rect(5, 5, 287, 200, 'D')
    pdf.set_font('Arial', 'B', 35)
    pdf.cell(0, 60, 'CERTIFICATE OF COMPLETION', ln=True, align='C')
    pdf.set_font('Arial', '', 20)
    pdf.cell(0, 20, 'Recognizing the active participation of:', ln=True, align='C')
    pdf.set_font('Arial', 'I', 40)
    pdf.cell(0, 30, name, ln=True, align='C')
    pdf.set_font('Arial', '', 15)
    pdf.cell(0, 20, f'In the activity: {activity}', ln=True, align='C')
    return pdf.output(dest='S').encode('latin-1')
with st.sidebar:
    st.title("πŸ™οΈ SK Portal")
    page = st.radio("Navigate to:", ["Dashboard", "Activity Feed", "Evaluation & Rewards"])
    st.info("Log in to track your points!")
if 'user_points' not in st.session_state:
    st.session_state.user_points = 85
if page == "Dashboard":
    st.header("πŸ† Youth Impact Leaderboard")
    
    col1, col2 = st.columns([1, 2])
    
    with col1:
        st.subheader("Your Stats")
        st.metric(label="Your Current Points", value=f"{st.session_state.user_points} pts", delta="+15 this week")
        st.progress(st.session_state.user_points / 200)
        st.caption("Next Rank: Silver Badge at 100 pts")

    with col2:
        data = {
            "Rank": [1, 2, 3, 4],
            "Name": ["Juan Dela Cruz", "Maria Clara", "You", "Kiko Matsing"],
            "Points": [150, 125, st.session_state.user_points, 50]
        }
        st.table(pd.DataFrame(data))
elif page == "Activity Feed":
    st.header("πŸ“’ Recent & Upcoming Activities")
    col_a, col_b = st.columns(2)
    
    with col_a:
        st.image("https://images.unsplash.com/photo-1544928147-79a2dbc1f389?w=500", caption="Coastal Cleanup")
        st.write("**Date:** Dec 15, 2025")
        st.button("View Photos", key="btn1")

    with col_b:
        st.image("https://images.unsplash.com/photo-1511632765486-a01980e01a18?w=500", caption="Youth Night")
        st.write("**Date:** Jan 5, 2026")
        st.button("Register Now", key="btn2")
elif page == "Evaluation & Rewards":
    st.header("πŸ“ Post-Activity Evaluation")
    st.write("Complete this form to earn **15 points** and your certificate.")
    
    with st.form("eval_form"):
        u_name = st.text_input("Full Name for Certificate")
        act = st.selectbox("Which activity did you attend?", ["Coastal Cleanup", "Tech Seminar"])
        rating = st.slider("Rate the activity", 1, 5)
        feedback = st.text_area("What can we improve?")
        submitted = st.form_submit_button("Submit & Claim Reward")
        
        if submitted:
            if u_name:
                st.session_state.user_points += 15
                st.success(f"Form submitted! You now have {st.session_state.user_points} points.")
                st.balloons()
                
                # Certificate Download
                cert_bytes = generate_pdf(u_name, act)
                st.download_button(
                    label="πŸŽ“ Download My Certificate",
                    data=cert_bytes,
                    file_name="SK_Certificate.pdf",
                    mime="application/pdf"
                )
            else:
                st.warning("Please enter your name to generate the certificate.")