Skip to content

Commit f0e1451

Browse files
authored
Merge pull request #7 from devinmatte/master
LDAP Stuff
2 parents d945a1c + 2a54c87 commit f0e1451

File tree

12 files changed

+121
-30
lines changed

12 files changed

+121
-30
lines changed

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,19 @@ config.py
108108

109109
# Generated Assets
110110
packet/static/css/packet.css
111-
*.min.css
111+
*.min.css
112+
packet/static/android-chrome-192x192.png
113+
packet/static/android-chrome-512x512.png
114+
packet/static/apple-touch-icon.png
115+
packet/static/browserconfig.xml
116+
packet/static/favicon-16x16.png
117+
packet/static/favicon-32x32.png
118+
packet/static/favicon.ico
119+
packet/static/mstile-144x144.png
120+
packet/static/mstile-150x150.png
121+
packet/static/mstile-310x150.png
122+
packet/static/mstile-310x310.png
123+
packet/static/mstile-70x70.png
124+
packet/static/safari-pinned-tab.svg
125+
packet/static/site.webmanifest
126+
faviconData.json

frontend/scss/components/_datatables.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ div {
2727
width: 100%;
2828
}
2929
}
30+
31+
.eval-blocks {
32+
margin-bottom: 30px;
33+
}
3034
}
35+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.sign-packet {
2+
float: right;
3+
text-align: right;
4+
}

frontend/scss/packet.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ $csh-pink: #b0197e;
33
@import "partials/base";
44

55
@import "components/switches";
6-
@import "components/datatables";
6+
@import "components/datatables";
7+
@import "components/buttons";

packet/ldap.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ def _ldap_is_member_of_group(member, group):
1717
return False
1818

1919

20-
def _ldap_add_member_to_group(account, group):
21-
if not _ldap_is_member_of_group(account, group):
22-
_ldap.get_group(group).add_member(account, dn=False)
23-
24-
25-
def _ldap_remove_member_from_group(account, group):
26-
if _ldap_is_member_of_group(account, group):
27-
_ldap.get_group(group).del_member(account, dn=False)
28-
29-
3020
@lru_cache(maxsize=1024)
3121
def _ldap_is_member_of_directorship(account, directorship):
3222
directors = _ldap.get_directorship_heads(directorship)
@@ -95,11 +85,19 @@ def ldap_get_eboard():
9585
) + _ldap_get_group_members("eboard-financial") + _ldap_get_group_members("eboard-history"
9686
) + _ldap_get_group_members("eboard-imps") + _ldap_get_group_members("eboard-opcomm"
9787
) + _ldap_get_group_members("eboard-research") + _ldap_get_group_members("eboard-social"
98-
) + _ldap_get_group_members("eboard-secretary")
88+
) + _ldap_get_group_members("eboard-secretary") + _ldap_get_group_members("eboard-pr")
9989

10090
return members
10191

10292

93+
def ldap_get_live_onfloor():
94+
members = []
95+
onfloor = ldap_get_onfloor_members()
96+
for member in onfloor:
97+
if ldap_get_roomnumber(member) and not ldap_is_eboard(member):
98+
members.append(member)
99+
return members
100+
103101
# Status checkers
104102

105103
def ldap_is_active(account):
@@ -165,4 +163,4 @@ def ldap_get_roomnumber(account):
165163
try:
166164
return account.roomNumber
167165
except AttributeError:
168-
return ""
166+
return None

packet/models.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
# The required number of off-floor and alumni signatures
1212
REQUIRED_MISC_SIGNATURES = 15
1313

14+
1415
def end_date():
1516
return datetime.now() + timedelta(days=14)
1617

18+
1719
class Freshman(db.Model):
1820
__tablename__ = "freshman"
1921
rit_username = Column(String(10), primary_key=True)
@@ -29,15 +31,16 @@ def current_packet(self):
2931
"""
3032
return self.packets[0]
3133

34+
3235
class Packet(db.Model):
3336
__tablename__ = "packet"
3437
id = Column(Integer, primary_key=True, autoincrement=True)
3538
freshman_username = Column(ForeignKey("freshman.rit_username"))
3639
start = Column(DateTime, default=datetime.now, nullable=False)
3740
end = Column(DateTime, default=end_date, nullable=False)
38-
info_eboard = Column(Text, nullable=True) # Used to fulfil the eboard description requirement
39-
info_events = Column(Text, nullable=True) # Used to fulfil the events list requirement
40-
info_achieve = Column(Text, nullable=True) # Used to fulfil the technical achievements list requirement
41+
info_eboard = Column(Text, nullable=True) # Used to fulfil the eboard description requirement
42+
info_events = Column(Text, nullable=True) # Used to fulfil the events list requirement
43+
info_achieve = Column(Text, nullable=True) # Used to fulfil the technical achievements list requirement
4144

4245
freshman = relationship("Freshman", back_populates="packets")
4346
upper_signatures = relationship("UpperSignature")
@@ -60,6 +63,7 @@ def signatures_received(self):
6063

6164
return upper_count + fresh_count + misc_count
6265

66+
6367
class UpperSignature(db.Model):
6468
__tablename__ = "signature_upper"
6569
packet_id = Column(Integer, ForeignKey("packet.id"), primary_key=True)
@@ -70,6 +74,7 @@ class UpperSignature(db.Model):
7074

7175
packet = relationship("Packet", back_populates="upper_signatures")
7276

77+
7378
class FreshSignature(db.Model):
7479
__tablename__ = "signature_fresh"
7580
packet_id = Column(Integer, ForeignKey("packet.id"), primary_key=True)
@@ -79,6 +84,7 @@ class FreshSignature(db.Model):
7984

8085
packet = relationship("Packet", back_populates="fresh_signatures")
8186

87+
8288
class MiscSignature(db.Model):
8389
__tablename__ = "signature_misc"
8490
packet_id = Column(Integer, ForeignKey("packet.id"), primary_key=True)

packet/routes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from packet.utils import before_request
99
from . import auth, app
1010
from .models import Freshman
11-
from .ldap import ldap_get_eboard
11+
from .ldap import ldap_get_live_onfloor, ldap_get_eboard
1212

1313

1414
@app.route("/")
@@ -20,6 +20,11 @@ def index(info=None):
2020
"name": "Testiboi",
2121
"signatures": 12,
2222
"uid": 111
23+
},
24+
{
25+
"name": "Ram Zallllllan",
26+
"signatures": 69,
27+
"uid": 420
2328
}
2429
]
2530
return render_template("active_packets.html", info=info, freshmen=freshmen)
@@ -29,8 +34,9 @@ def index(info=None):
2934
@auth.oidc_auth
3035
@before_request
3136
def freshman_packet(uid, info=None):
37+
onfloor = ldap_get_live_onfloor()
3238
eboard = ldap_get_eboard()
33-
return render_template("packet.html", info=info, eboard=eboard, uid=uid)
39+
return render_template("packet.html", info=info, eboard=eboard, onfloor=onfloor, uid=uid)
3440

3541

3642
@app.route("/csh-auth/")

packet/static/manifest.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"background_color": "#FFF",
3+
"description": "CSH WebPacket",
4+
"dir": "auto",
5+
"display": "standalone",
6+
"lang": "en",
7+
"name": "CSH Packet",
8+
"orientation": "portrait",
9+
"short_name": "Packet",
10+
"start_url": "/",
11+
"theme_color": "#b0197e",
12+
"icons": [
13+
{
14+
"src": "/static/android-chrome-192x192.png",
15+
"sizes": "192x192",
16+
"type": "image/png"
17+
},
18+
{
19+
"src": "/static/android-chrome-512x512.png",
20+
"sizes": "512x512",
21+
"type": "image/png"
22+
}
23+
]
24+
}

packet/templates/active_packets.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ <h3 class="page-title">Active Packets</h3>
2828
{% for m in freshmen %}
2929
<tr>
3030
<td>
31-
<img class="eval-user-img" alt="{{ m['uid'] }}"
32-
src="https://profiles.csh.rit.edu/image/{{ m['uid'] }}"
33-
width="30"
34-
height="30"/> {{ m['name'] }}
31+
{{ m['name'] }}
3532
</td>
3633
<td>
3734
<span class="glyphicon glyphicon-ok-sign green eval-info-status"></span>
@@ -41,8 +38,12 @@ <h3 class="page-title">Active Packets</h3>
4138
<span class="glyphicon glyphicon-ok-sign green eval-info-status"></span>
4239
{{ m['total_percent'] }}
4340
</td>
44-
<td>
45-
Sign Packet Button
41+
<td class="sign-packet" align="right">
42+
{# if not signed #}
43+
<button class="btn btn-primary">Sign</button>
44+
{# else if signed #}
45+
<button class="btn btn-primary" disabled="disabled"><i class="fa fa-check"></i>&nbsp;Signed</button>
46+
{# endif #}
4647
</td>
4748
</tr>
4849
{% endfor %}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<footer class="py-5 bg">
22
<div class="container">
3-
<p class="m-0 text-center text-white"><a href="https://github.com/ComputerScienceHouse/packet">{{ info.git_revision }}</a>
3+
<p class="m-0 text-center text-white"><a href="https://github.com/ComputerScienceHouse/packet"> CSH Packet 3.0.0</a>
44
</p>
55
</div>
66
</footer>

0 commit comments

Comments
 (0)